1.
/*
Name:quicksort(从小到大)
Coder:LJh
Time:3'46
Debug过程:发现漏写"using namespace std;"
Instruction:
intput: 第一行:n//代表排序数字数量
第二行:n个数字,空格隔开
output:n个数字从小到大输出
算法思想参考:http://developer.51cto.com/art/201403/430986.htm
*/
#include<iostream>
#include<algorithm>
using namespace std;
int a[100];
void quicksort(int i,int j)
{
while(i<j){
int i0=i,j0=j;
int temp=a[i0];
while(i<j){
while(a[j]>=temp&&i<j){
j--;
};
while(a[i]<=temp&&i<j){
i++;
};
swap(a[i],a[j]);
}
swap(a[i],a[i0]);
quicksort(i0,i-1);
quicksort(i+1,j0);
}
}
int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
}
quicksort(0,n-1);
for(int i=0;i<n;i++){
cout<<a[i]<<" ";
}
cout<<endl;
return 0;
}