#include<stdio.h>
//快速排序
int quick_sort(int arr[], int len, int left, int right)
{
int i, j, t, temp;
if (left >= right)
return;
temp = arr[left];
i = left+1;
j = right;
while(i!=j){
while ( arr[j]>=temp && i<j ){
j--;
}
while ( arr[i]<temp && i<j){
i++;
}
if (i<j){
t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
}
arr[left] = arr[i];
arr[i] = temp;
quick_sort(arr, len, left, i-1);
quick_sort(arr, len, i+1, right);
}
//显示数组的内容
int show_array(int arr[], int len)
{
printf("\n");
int i;
for (i = 0; i < len; i++)
printf("%d ", arr[i]);
}
int main() {
int arr[] = { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 };
int len = (int) sizeof(arr) / sizeof(*arr);
show_array(arr, len);
quick_sort(arr, len, 0, len-1);
show_array(arr, len);
return 0;
}