15

 1 package cn.lyh;
 2 
 3 public class L {
 4 
 5     public static void main(String[] args) {
 6         int []arr = new int[30]; 
 7         arr[0]=1;
 8         arr[1]=1;
 9         for(int i=2;i<arr.length;i++)
10             arr[i]=arr[i-1]+arr[i-2];
11         for(int i:arr)
12             System.out.print(i+"");
13 
14     }
15 
16 
17 
18 
19 package cn.lyh;
20 
21 public class L {
22 
23     public static void main(String[] args) {
24 
25         liker  ker[]=new liker[3];
26         ker[0]=new liker("Mr、L",11);
27         ker[1]=new liker("Mr、Y",17);
28         ker[2]=new liker("Mr、H",19);
29         for(int i=0;i<ker.length;i++)
30             ker[i].getInfo();
31     }
32     
33 }
34     class liker {
35         private String name;
36         private int age;
37         public liker(String name,int age){
38             this.name=name;
39             this.age=age;
40         }
41         public void getInfo() {
42             System.out.println("姓名:" + this.name + "     年龄:" + this.age);
43         }
44     }
45 
46 }
47 
48 
49 
50 package cn.lyh;
51 
52 public class L {
53 
54     public static void main(String[] args) {
55             int array[]= {0,8,4,6,2,5,3,7,9,1};
56         for(int i=0;i<array.length;i++)
57             for(int j=0;j<array.length-i-1;j++) {
58                 if(array[j]>array[j+1]) {
59                     int temp =array[j];
60                     array[j]=array[j+1];
61                     array[j+1]=temp;
62                 }
63             }
64         for( int i:array)
65             System.out.print(i+"  ");
66     }
67     
68 }
69 
70 
71 
72 
73 package cn.lyh;
74 
75 public class L {
76 
77     public static void main(String[] args) {
78                 int array[]= {0,8,4,6,2,5,3,7,9,1};  //选择排序法
79         for(int i=0;i<array.length;i++)
80             for(int j=i+1;j<array.length;j++) {
81                 if(array[j]>array[i]) {
82                     int temp =array[j];
83                     array[j]=array[i];
84                     array[i]=temp;
85                 }
86             }
87         for( int i:array)
88             System.out.print(i+"  ");
89     }
90     
91 }

原文地址:https://www.cnblogs.com/a718204806/p/8057497.html