#include<stdio.h> int partition(int a[],int low,int high) { int key=a[low]; while(low<high) { while(low<high&&a[high]>key) high--; if(low<high) a[low]=a[high]; while(low<high&&a[low]<key) low++; if(low<high) a[high]=a[low]; } a[low]=key; return low; }//确定中枢轴位置 void quickSort(int a[],int low,int high) { int keylocation; if(low<high) { keylocation=partition(a,low,high); quickSort(a,low,keylocation-1); quickSort(a,keylocation+1,high); } }//l利用递归实现 int main() { int a[10]; int i; for(i=0;i<10;i++) { scanf("%d",&a[i]); } quickSort(a,0,9); for(i=0;i<10;i++) printf(" %d",a[i]); putchar(10); return 0; }