#include<iostream>
using namespace std;
typedef struct{
int length;
int *e;
}shuzu;
int Init(shuzu &L){
L.e=new int[6];
L.e[0]=0;
L.e[1]=23;
L.e[2]=46;
L.e[3]=37;
L.e[4]=50;
L.e[5]=14;
L.length=6;
return 0;
}
int shuchu(shuzu L){
for(int i=1;i<L.length;i++)
cout<<L.e[i]<<" ";
return 0;
}
int charu(shuzu &L){//直接插入排序
for(int i=2;i<L.length;i++){
if(L.e[i]<L.e[i-1]){
L.e[0]=L.e[i];
L.e[i]=L.e[i-1];
for(int j=i-2;L.e[j]>L.e[0];j--)
L.e[j+1]=L.e[j];
L.e[j+1]=L.e[0];
}}
return 0;
}
int zheban(shuzu &L)//折半排序
{
for(int i=2;i<L.length;++i){
L.e[0]=L.e[i];
int low=1;
int high=i-1;
while(low<=high)
{
int m=(low+high)/2;
if(L.e[0]<L.e[m]) high=m-1;
else low=m+1;
}
for(int j=i-1;j>=high+1;j--)
L.e[j+1]=L.e[j];
L.e[high+1]=L.e[0];
}
return 0;
}
int xuanze(shuzu &L){//选择排序
for(int i=1;i<L.length;i++)
{int min=L.e[i];int s=i;
for(int j=i+1;j<L.length;j++){
if(L.e[j]<min){ min=L.e[j];s=j;}
}
if(s!=i){int p=L.e[i];L.e[i]=L.e[s];L.e[s]=p;}
}
return 0;
}
int maopao(shuzu&L){//冒泡排序
for(int i=1;i<L.length;i++)
for(int j=1;j<L.length-i+1;j++)
{
if(L.e[j]<L.e[j-1])
{int s=L.e[j];
L.e[j]=L.e[j-1];
L.e[j-1]=s;}
}
return 0;
}
int main(){
shuzu a;
Init(a);
shuchu(a);cout<<endl;
//xuanze(a);
// zheban(a);shuchu(a);cout<<endl;
//charu(a);
maopao(a);
shuchu(a);
return 0;
}
using namespace std;
typedef struct{
int length;
int *e;
}shuzu;
int Init(shuzu &L){
L.e=new int[6];
L.e[0]=0;
L.e[1]=23;
L.e[2]=46;
L.e[3]=37;
L.e[4]=50;
L.e[5]=14;
L.length=6;
return 0;
}
int shuchu(shuzu L){
for(int i=1;i<L.length;i++)
cout<<L.e[i]<<" ";
return 0;
}
int charu(shuzu &L){//直接插入排序
for(int i=2;i<L.length;i++){
if(L.e[i]<L.e[i-1]){
L.e[0]=L.e[i];
L.e[i]=L.e[i-1];
for(int j=i-2;L.e[j]>L.e[0];j--)
L.e[j+1]=L.e[j];
L.e[j+1]=L.e[0];
}}
return 0;
}
int zheban(shuzu &L)//折半排序
{
for(int i=2;i<L.length;++i){
L.e[0]=L.e[i];
int low=1;
int high=i-1;
while(low<=high)
{
int m=(low+high)/2;
if(L.e[0]<L.e[m]) high=m-1;
else low=m+1;
}
for(int j=i-1;j>=high+1;j--)
L.e[j+1]=L.e[j];
L.e[high+1]=L.e[0];
}
return 0;
}
int xuanze(shuzu &L){//选择排序
for(int i=1;i<L.length;i++)
{int min=L.e[i];int s=i;
for(int j=i+1;j<L.length;j++){
if(L.e[j]<min){ min=L.e[j];s=j;}
}
if(s!=i){int p=L.e[i];L.e[i]=L.e[s];L.e[s]=p;}
}
return 0;
}
int maopao(shuzu&L){//冒泡排序
for(int i=1;i<L.length;i++)
for(int j=1;j<L.length-i+1;j++)
{
if(L.e[j]<L.e[j-1])
{int s=L.e[j];
L.e[j]=L.e[j-1];
L.e[j-1]=s;}
}
return 0;
}
int main(){
shuzu a;
Init(a);
shuchu(a);cout<<endl;
//xuanze(a);
// zheban(a);shuchu(a);cout<<endl;
//charu(a);
maopao(a);
shuchu(a);
return 0;
}