赞
踩
十大排序经典排序算法
- //插入排序
- #include<stdio.h>
- int main()
- {
- int x[5] = {26,1,8,45,22};
- int i, j;
- int temp;//临时变量,做记录
- for (i = 1; i < 5; i++)
- {
- temp = x[i];
- for (j = i; j > 0 && x[j - 1] > temp; j--)
- x[j] = x[j-1];//向后移一位
- x[j] = temp;
- }
- for (i = 0; i < 5; i++)
- printf("%d\t ",x[i]);
- return 0;
- }
-
![](https://csdnimg.cn/release/blogv2/dist/pc/img/newCodeMoreWhite.png)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。