using namespace std;
//插入排序--直接插入排序
void insert_sort(int v[],int lenth)
{
int i,j;
for(i=1;i
int tem = v[i];
for(j=i-1;j>=0&&tem
v[j+1] = tem;
}
}
//插入排序--shell(希尔)排序(快速插入排序)
void shell(int v[],int lenth)//在直接插入排序的基础上分段做插入排序
{
int i,j,step;
for(step=lenth/2;step>=1;step=step/2)
{
for(i=step;i
int tem = v[i];
for(j=i-step;j>=0&&tem
v[j+step] = tem;
}
}
}
//交换排序--泡沫排序
void bubble(int v[],int lenth)
{
int i,j;
for(i=1;i
if(v[j]
int tem = v[j-1];
v[j-1] = v[j];
v[j] = tem;
}
}
//交换排序--快速排序
int partition(int v[],int low,int high)//一种分段方法
{
int i=low,j=high;
int tem = v[low];
while(i
while(i
j--;
if(i
v[i++] = v[j];
}
while(i
if(i
v[j--] = v[i];
}
}
v[i] =tem;
return i;
}
void quicksort(int v[],int low,int high)
{
int point;
if(low
point = partition(v,low,high);
quicksort(v,low,point-1);
quicksort(v,point+1,high);
}
}
//选择排序--直接选择排序
void select(int v[],int lenth)
{
int i,j;
int tem_data;
int tem_i;
for(i=0;i
tem_data = v[i];
tem_i = i;
for(j=i+1;j
tem_data = v[j];
tem_i = j;
}
if(i!=tem_i)
{
v[tem_i] = v[i];
v[i] = tem_data;
}
}
}
void show(int v[],int lenth)
{
int i;
for(i=0;i<10;i++)
cout<
int main(void)
{
int a[10] = {10,49,38,65,97,76,3,49,27,1};
cout<
show(a,10);
int b[10] = {10,49,38,65,97,76,3,49,27,1};
cout<
show(b,10);
int c[10] = {10,49,38,65,97,76,3,49,27,1};
cout<
show(c,10);
int d[10] = {10,49,38,65,97,76,3,49,27,1};
cout<
show(d,10);
int e[10] = {10,49,38,65,97,76,3,49,27,1};
cout<
show(e,10);
}