public class insertSort{
public static void main(String args[]){
int a[] = {2, 4, 6, 3, 7, 12, 44, 23, 54, 32};
int temp = 0;
for(int i = 1; i < a.length; i++){
int j = i - 1;
temp = a[i];
for(j = i - 1; j >= 0 && temp < a[j]; j--){
a[j +1] = a[j];
}
a[j +1] = temp;
}
for(int i = 0; i < a.length; i++){
System.out.print(a[i] +" ");
}
}
}
2967

被折叠的 条评论
为什么被折叠?



