#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int Partition(int *a,int low,int high){
int t;
t=a[low];
while(low<high){
while(low<high&&t<=a[high]) high--;
a[low]=a[high];
while(low<high&&t>=a[low]) low++;
a[high]=a[low];
}
a[low]=t;
return low;
}
void QSort(int a[],int low,int high){
if(low<high){
int pivotloc=Partition(a,low,high);
QSort(a,low,pivotloc-1);
QSort(a,pivotloc+1,high);
}
}
int main()
{
int a[100];
int x,i=1;
cin>>x;
while(x){
a[i++]=x;
cin>>x;
}
QSort(a,1,i-1);
for(int j=1;j<=i-1;j++)
cout<<a[j]<<" ";
//cout << "Hello world!" << endl;
return 0;
}
8549 快速排序
猜你喜欢
转载自blog.csdn.net/changbaishannefu/article/details/111648103
今日推荐
周排行