标签:
1 public class Paixu_charu { 2 int[] a=new int[] {8,5,7,9,1,6,7,4,2,6}; 3 public static void main(String[] args) { 4 Paixu_charu h=new Paixu_charu(); 5 h.go(); 6 } 7 public void go(){ 8 int out=1; 9 int in; 10 int temp; 11 while(out<10){ 12 temp=a[out]; 13 in=out; 14 while(in>0&&a[in-1]>temp){ 15 a[in]=a[in-1]; 16 in--; 17 } 18 a[in]=temp; 19 out++; 20 } 21 display(); 22 } 23 24 public void display(){ 25 for(int i=0;i<a.length;i++){ 26 System.out.print(a[i]); 27 } 28 } 29 }
标签:
原文地址:http://www.cnblogs.com/shortail/p/5047062.html