void quick(int b[],int left,int right)
{
int s,t,i,j;
if(left<right)
{
s=b[(left+right)/2];
i=left-1; j=right+1;
while(1)
{
while(b[++i]<s);
while(b[--j]>s);
if(i>=j) break;
t=b[i];
b[i]=b[j];
b[j]=t;
}
quick(b,left,i-1);
quick(b,j+1,right);
}
}
int main()
{
int i,j;
int a[132],c[123];
while(scanf("%d",&i)==1)
{
for(j=0; j<i; j++)
scanf("%d",&c[j]);
quick(c,0,i-1);
for(j=0;j<i;j++)
printf("%d ",c[j]);
printf("\n");
for(j=0; j<i; j++)
scanf("%d",&a[j]);
quick(a,0,i-1);
for(j=0;j<i;j++)
printf("%d ",a[j]);
printf("\n");
}
return 0;
}
No comments:
Post a Comment