69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
void insertSort(int e[],int n)
{
int i,j;
int temp;
for(i=1;i<n;i++)
{
temp=e[i];
for(j=i-1;j>=0;j--)
{
if(e[j]<temp)
{
break;
}
e[j+1]=e[j];
}
e[j+1]=temp;
}
}
int main(void)
{
int i;
int e[]={21,23,12,45,39};
insertSort(e,5);
//printf("%d",e);
for(i = 0; i<5 ;i++)
printf("%d ",e[i]);
return 0;
}