package cn.cty; public class L { public static void main(String[] args) { int []arr = new int[30]; arr[0]=1; arr[1]=1; for(int i=2;i<arr.length;i++) arr[i]=arr[i-1]+arr[i-2]; for(int i:arr) System.out.print(i+" 、"); } }
package cn.cty; public class L { public static void main(String[] args) { liker ker[]=new liker[3]; ker[0]=new liker("Mr、L",11); ker[1]=new liker("Mr、Y",17); ker[2]=new liker("Mr、H",19); for(int i=0;i<ker.length;i++) ker[i].getInfo(); } } class liker { private String name; private int age; public liker(String name,int age){ this.name=name; this.age=age; } public void getInfo() { System.out.println("姓名:" + this.name + " 年龄:" + this.age); } }
package cn.cty; public class L { public static void main(String[] args) { int array[]= {0,8,4,6,2,5,3,7,9,1}; for(int i=0;i<array.length;i++) for(int j=0;j<array.length-i-1;j++) { if(array[j]>array[j+1]) { int temp =array[j]; array[j]=array[j+1]; array[j+1]=temp; } } for( int i:array) System.out.print(i+" "); } }
package cn.cty; public class L { public static void main(String[] args) { int array[]= {0,8,4,6,2,5,3,7,9,1}; //选择排序法 for(int i=0;i<array.length;i++) for(int j=i+1;j<array.length;j++) { if(array[j]>array[i]) { int temp =array[j]; array[j]=array[i]; array[i]=temp; } } for( int i:array) System.out.print(i+" "); } }