java練習---15

來源:互聯網
上載者:User

標籤:年齡   info   ati   java   system   --   stat   new   col   

 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 }
package cn.lyh;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.lyh;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.lyh;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+"  ");    }    }

 

 

java練習---15

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.