#include<iostream>
using namespace std;
#define SIZE 10
void Insert_Sort(int array[]);
void Show_Array(int array[]);
void main()
{
int array[SIZE]={12,4512,65,45,21,76,122,67,32,9};
Insert_Sort(array);
Show_Array(array);
}
void Insert_Sort(int array[])
{
int i,j;
int temp;
for (i=1;i<SIZE;i++) //第一个数已有序
{
temp=array[i];
j=i-1;
for (j;j>=0 && array[j]>temp;j--) //在有序序列中找比temp大的数,并将其顺序后移
{
array[j+1]=array[j];
}
array[j+1]=temp;
}
}
void Show_Array(int array[])
{
int i;
for (i=0;i<SIZE;i++)
{
cout<<array[i]<<" ";
}
}