?? 6-7-2.cpp
字號:
#include <iostream.h>
void InsertSort(int slist[], int n)
{ int temp;
int i,j;
for (i=1; i < n; i++) {
temp = slist[i];
j=i;
while (j>0 && temp < slist[j-1]) {
slist[j]=slist[j-1];
j--;
} //查找與移動同時做
slist[j] = temp;
}
}
void main()
{ int a[] = {8, 6, 7, 9, 4, 5, 2};
InsertSort(a, 7); cout << "排序后的數據是:";
for(int i=0; i < 7; i ++) cout << a[i] << ",";
cout << endl;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -