#include<iostream>
using namespace std;
//定义1个交换函数
void swap(int &a,int &b)
{
int tmp;
tmp=a;
a=b;
b=tmp;
}
void InsertSort(int *A,int length)
{
int i,j;
for(int i=1;i<length;++i)
{
if(A[i]<A[i⑴])
{
int j=i;
while(A[j]<A[j⑴]&&j>=1)
{
swap(A[j],A[j⑴]);
j--;
}
}
}
}
int main()
{ int a[9]={9,1,5,8,3,7,4,6,2};
InsertSort(a,9);
for(int i=0;i<9;++i)
cout<<a[i]<<" ";
cout<<endl;
system("pause");
return 0;
}