#include <iostream>
using namespace std;
void Show(int* pList, int nCount)
{
for (int nIndex = 0; nIndex < nCount; nIndex++)
cout << pList[nIndex] << "\t";
cout << endl;
}
void InsertSort(int* pList,int nCount)
{
for (int nIndex = 1; nIndex < nCount; nIndex++)
{
int nSave = pList[nIndex];
int nMove;
for (nMove = nIndex - 1; nSave < pList[nMove]; nMove--)
pList[nMove + 1] = pList[nMove];//往后移动腾出位置
pList[nMove + 1] = nSave;
}
}
int main(int argc, char* argv[], char* envp[])
{
int pList[] = { 97,64,28,46,15,35,82,44,66,95 };
int nCount = sizeof(pList) / sizeof(int);
InsertSort(pList, nCount);
Show(pList, nCount);
getchar();
return 0;
}