摘要: #include <stdio.h> #define N 10 struct student { int num; char name[30]; int score[3]; int ave; } input(struct student s[]) { int i; for(i=0;i<N;i++) 阅读全文
posted @ 2016-05-25 17:41 张不二 阅读(201) 评论(0) 推荐(0)
摘要: 1.泛化关系:类和类之间继承,接口与接口直接继承 2.实现关系:类和接口对接 3.关联关系:一个类可以知道另一个类的属性方法 4.聚合关系:较强的关联关系,不像关联关系那样平等,这个是一个整体一个部分。(整体无法决定部分) 5.合成关系:和聚合一样,区别是 整体决定部分 is-a: 继承 is-li 阅读全文
posted @ 2016-05-15 20:29 张不二 阅读(360) 评论(0) 推荐(0)
摘要: public class LX { public static void main(String[] args) { int[][] c=new int[20][20]; int i,j,k=1; for(i=0;i=0;j--) { c[7-i-1][j]=k++; ... 阅读全文
posted @ 2016-05-06 18:30 张不二 阅读(1165) 评论(0) 推荐(0)
摘要: #include main() { int c[20][20],i,j,k; k=1; for(i=0;i=0;j--) { c[7-i-1][j]=k++; } for(j=7-2-i;j>i;j--) { c[j][i]=k++; } ... 阅读全文
posted @ 2016-05-06 18:17 张不二 阅读(246) 评论(1) 推荐(0)
摘要: public class Animal { public void eat(){ System.out.println("动物在吃东西"); } } public class Cat extends Animal{ public void eat(){ System.out.println("猫吃鱼!"); } } public... 阅读全文
posted @ 2016-04-24 20:12 张不二 阅读(124) 评论(0) 推荐(0)
摘要: import java.util.Scanner; public class Test { private static String num; private static String cla; private static String name; public static void main(String[] args) { ... 阅读全文
posted @ 2016-04-18 21:07 张不二 阅读(508) 评论(0) 推荐(0)
摘要: 引入继承最基本的作用是:代码重用。 语法: [修饰符列表] class 子类名 extends 父类名 java语言中,类和类只支持单继承。 一个类如果没有显示的继承其他类,则该类默认继承object(object是sum提供的java的根类)。 子类可以继承父类的所有,包括私有的也可以,但是继承过 阅读全文
posted @ 2016-04-13 21:21 张不二 阅读(245) 评论(0) 推荐(0)
摘要: 构造方法是一种特殊的方法,与一般的方法不同是: 1.构造方法的名字必须与定义他的类名完全相同,没有返回类型,甚至连void也没有。 2.构造方法的调用是在创建一个对象时使用new操作进行的。构造方法的作用是初始化对象。 3.不能被static、final、synchronized、abstract和 阅读全文
posted @ 2016-04-13 20:38 张不二 阅读(335) 评论(0) 推荐(0)
摘要: public class S { public static void main(String args[]) { for(int i=1;i<=9;i++) { for(int j=1;j<=i;j++) {int s; s=i*j; if(j<i) ... 阅读全文
posted @ 2016-04-04 19:27 张不二 阅读(173) 评论(0) 推荐(0)
摘要: public class First{ public static void main(String args[]){ System.out.println(method(10)); } public static int method(int n){ if(n==1) return 1; else return n + method(n-1); } } 阅读全文
posted @ 2016-04-04 19:26 张不二 阅读(119) 评论(0) 推荐(0)