#include <stdio.h>
void main(){
int i,j,k,t,n;
int a[5] = {3,2,8,1,9};
n = sizeof(a)/sizeof(a[0]);
for(i=1;i<n;i++){
if(a[i]<a[i-1]){
j = i-1;
t= a[i];
while(j>=0&&a[j]>t){
a[j+1] = a[j];
j--;
}
a[j+1] = t;
}
}
for(k=0;k<n;k++){
printf("%d->",a[k]);
}
}
Data structure-inner sort-direct insertion sort (array implementation, C language, sequence table is the same)
Guess you like
Origin blog.csdn.net/qq_24130591/article/details/109712046
Recommended
Ranking