插入排序

来源:互联网 发布:张坤淘宝店 编辑:程序博客网 时间:2024/05/29 07:29
void main(){int a[10] = { 1, 8, 9, 45, 15, 67, 8, 15, 4, 23 };for (int i = 0; i < 10 - 1; i++){int temp = a[i];int j = i;while (j>0 && a[j - 1] > temp){a[j] = a[j - 1];j--;}a[j] = temp;}printf("\n\n");for (int i = 0; i < 10; i++){printf("%d   ", a[i]);}system("pause");}

1 0
原创粉丝点击