#include <iostream>
using namespace std;
void insert_sort(int array[],int length)
{
int i,j,temp;
for(i=1;i<length;i++)
{
temp=array[i];
for(j=i-1;j>=0&&array[j]>temp;j--)
array[j+1]=array[j];
array[j+1]=temp;
}
}
int main()
{
int myarray[]={2,1,0,8,9,3,4,6,5,7};
insert_sort(myarray,sizeof(myarray)/sizeof(int));
for(int i=0;i<sizeof(myarray)/sizeof(int);i++)
cout<<myarray[i]<<" ";
cout<<endl;
return 0;
}
//0 1 2 3 4 5 6 7 8 9
insert_sort
最新推荐文章于 2023-07-26 17:45:51 发布