日期:2014-05-20 浏览次数:20991 次
public class Sorts {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a[]={4,3,2,5,1};
int temp=0;
for(int i=0;i<a.length;i++){
for(int j=i;j>0&&(a[j]<a[j-1]);j--){
temp=a[j];
a[j]=a[j-1];
a[j-1]=temp;
}
}
for(int i:a){
System.out.print(i+" ");
}
}
}