1 #include<stdio.h>
2 #include<stdlib.h>
3
4 int a[7] = { 4,8,33,-3,34,55,10 };
5
6 int FindPos(int *a, int low, int high)
7 {
8 int val = a[low];
9 while (low < high)
10 {
11 while (a[high] >= val && low < high)
12 high--;
13 a[low] = a[high];
14 while (a[low] <= val && low < high)
15 low++;
16 a[high] = a[low];
17 }
18 a[low] = val;
19 return low;
20 }
21 void QuickSort(int *, int low, int high)
22 {
23 int pos;
24 if (low < high)
25 {
26 pos = FindPos(a, low, high);
27 QuickSort(a, low, pos - 1);
28 QuickSort(a, pos + 1, high);
29 }
30 }
31 int main(void)
32 {
33 int i;
34 QuickSort(a, 0, 6);
35 for (i = 0; i < 7; i++)
36 {
37 printf("%d ", a[i]);
38 }
39 printf("\n");
40 system("pause");
41 return 0;
42 }