#include<iostream>
using namespace std;
void InsertSort(int a[],int n)
{
int temp,i,j;
for(int i=1;i<n;i++)
{
temp=a[i];
for(j=i-1;j>=0;j--)
{
if(a[j]>temp)
{
a[j+1]=a[j];
}
else
{
break;
}
}
a[j+1]=temp;
}
}
int main()
{
int a[11]={11,9, 20, 7, 56, 9, 42, 3, 7,15,16};
cout<<"排序前为:"<<endl;
for(int i=0;i<9;i++)
cout<<" "<<a[i];
cout<<endl;
InsertSort(a,9);
cout<<"排序结果为:"<<endl;
for(int i=0;i<9;i++)
cout<<" "<<a[i];
cout<<endl;
return 0;
}