parent
9477558b41
commit
6b9e5dedaa
@ -1,57 +0,0 @@
|
|||||||
# Sortmethod
|
|
||||||
void kuaipai(int array[],int low,int hight)
|
|
||||||
{
|
|
||||||
int i,j,t,m;
|
|
||||||
if(low<hight)
|
|
||||||
{
|
|
||||||
i=low;
|
|
||||||
j=hight;
|
|
||||||
t=array[low];
|
|
||||||
while(i<j)
|
|
||||||
{
|
|
||||||
while(i<j && array[j]>t)
|
|
||||||
j--;
|
|
||||||
if(i<j)
|
|
||||||
{
|
|
||||||
m=array[i];
|
|
||||||
array[i]=array[j];
|
|
||||||
array[j]=m;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
while(i<j && array[i]<=t)
|
|
||||||
i++;
|
|
||||||
if(i<j)
|
|
||||||
{
|
|
||||||
m=array[j];
|
|
||||||
array[j]=array[i];
|
|
||||||
array[i]=m;
|
|
||||||
j--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
array[i]=t;
|
|
||||||
kuaipai(array,0,i-1);
|
|
||||||
kuaipai(array,i+1,hight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void PX_kuaipai(int buf[],int size)
|
|
||||||
{
|
|
||||||
kuaipai(buf,0,size-1);
|
|
||||||
}
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
int m,i;
|
|
||||||
cin>>m;
|
|
||||||
int *buf=new int[m];
|
|
||||||
for(i=0;i<m;i++)
|
|
||||||
cin>>buf[i];
|
|
||||||
PX_kuaipai(buf,m);
|
|
||||||
for(i=0;i<m;i++)
|
|
||||||
cout<<buf[i];
|
|
||||||
cout<<'\n';
|
|
||||||
delete []buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in new issue