#SIZE 10
//直接插入排序
void insert_sort(){
int i,j;
int array[SIZE+1];
array[]={0,12,23,11,55,2,34,18,20,48,22};
for(i=2;i<=SIZE;i++){
array[0]=array[i];
j=i-1;
while(array[0]<array[j]){
array[j+1]=array[j];
j--;
}
array[j+1]=array[0];
}
}
//折半插入排序
void insert_binary_sort(){
int j,i,low,hight,m;
int array[SIZE+1];
for(i=2;i<=SIZE;i++){
array[0]=array[i];
hight=i-1;
low=1;
while(low<=hight)
{
m=(low+hight)/2;
if(array[0]<array[m])
hight=m-1;
else low=m+1;
}
for(j=i;j>hight+1;j--)
{
array[j]=array[j-1];
}
array[hight+1]=array[0];
}
}
//shell排序,在直接插入排序上进行优化而来
void shell_sort(){
int d,n,j,i;
int array[SIZE+1];
int d=n;
do{
d=d/2;
for(i=d+1;i<=SIZE;i++)
{
array[0]=array[i];
for(j=i-d;j>0&&array[j]>array[0];j-=d){
array[j+d]=array[j];
}
array[j+d]=array[0];
}
}while(d!=1);
}
//直接插入排序
void insert_sort(){
int i,j;
int array[SIZE+1];
array[]={0,12,23,11,55,2,34,18,20,48,22};
for(i=2;i<=SIZE;i++){
array[0]=array[i];
j=i-1;
while(array[0]<array[j]){
array[j+1]=array[j];
j--;
}
array[j+1]=array[0];
}
}
//折半插入排序
void insert_binary_sort(){
int j,i,low,hight,m;
int array[SIZE+1];
for(i=2;i<=SIZE;i++){
array[0]=array[i];
hight=i-1;
low=1;
while(low<=hight)
{
m=(low+hight)/2;
if(array[0]<array[m])
hight=m-1;
else low=m+1;
}
for(j=i;j>hight+1;j--)
{
array[j]=array[j-1];
}
array[hight+1]=array[0];
}
}
//shell排序,在直接插入排序上进行优化而来
void shell_sort(){
int d,n,j,i;
int array[SIZE+1];
int d=n;
do{
d=d/2;
for(i=d+1;i<=SIZE;i++)
{
array[0]=array[i];
for(j=i-d;j>0&&array[j]>array[0];j-=d){
array[j+d]=array[j];
}
array[j+d]=array[0];
}
}while(d!=1);
}