插入排序

来源:互联网 发布:极乐净土网页js代码 编辑:程序博客网 时间:2024/06/06 12:32
void charu(int a[])//插入排序
{
int temp;
int i,j;
for ( i = 1; i < 10; ++i)
{
temp = a[i];
for (j = i - 1; j >=0 ; j--)
{
if (a[j] > temp)
{
a[j+1] = a[j];
print(a);
}
else
{
break;
}

}
a[j+1] = temp;
}
}






int main()
{
int a[10] = {10,1,8,4,5,7,6,3,2,9};
charu(a);
print(a);


    return 0;
}
原创粉丝点击