插入排序
#include<stdio.h>
int main()
{
int n,a[100];
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(int i=1;i<n;i++){
int current = a[i];
int j = i-1;
while(a[j] > current && j>=0){
a[j+1] = a[j];
j--;
}
a[j+1] = current;
}
printf("***********************\nresult of this insert sort:\n");
for(int i=0;i<n;i++){
printf("%d ",a[i]);
}
return 0;
}
/*
10
9 5 6 4 10 3 8 2 7 1
15
15 14 13 12 11 9 5 6 4 10 3 8 2 7 1
*/