#include<iostream>
using namespace std;
int Pquicksort(int a[], int s, int t);
int main()
{
int i,n, a[200];
cin >> n;
for (i = 0; i < n; i++)
{
cin >> a[i] ;
}
Pquicksort(a ,0, n - 1);
for (i = 0; i < n; i++)
{
cout << a[i] << " ";
}
return 0;
}
//快速排序
int Pquicksort(int a[], int s, int t)//划分算法
{
int i = s, j = t, temp = 0;
int tmp = a[s];//用序列的第一个记录作为基准
while (i != j)//从序列两段从中间交替扫描,直至i=j
{
while (i < j && a[j] >= tmp)
j--;//从右向左扫描,找第一个关键字小于tmp的a[j];
while (i < j && a[i] <= tmp)
i++;
//交换
if (i < j)
{
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}
a[s] = a[i];
a[i] = tmp;
Pquicksort(a ,s, i - 1);
Pquicksort(a , i + 1, t);
return 0;
}
求改BUG。。。。。我找不到其他的BUG 了