1#include"stdafx.h"2#include"stdlib.h"3 4 intPartition (int*arr,int_low,int_high);5 voidQSort (int*arr,intLowintHigh );6 voidQuickSort (int*arr,intLowintHigh );7 voidSwap_a (int*arr,intIintj);8 int_tmain (intARGC, _tchar*argv[])9 {Ten intarr[Ten] = {1,2,0,9,3,5,4,6,8,7}; OneQuickSort (arr,0,9); A - for(intI=0;i<Ten;++i) - { theprintf"%d\t", Arr[i]); - } -System"Pause"); - return 0; + } - + intPartition (int*arr,intLowintHigh ) A { at intPivotKey; -PivotKey = * (arr+Low ); - while(low<High ) - { - while(LowPivotKey) -high--; in swap_a (arr,low,high); - while(LowPivotKey) tolow++; + swap_a (arr,low,high); - the } * returnLow ; $ }Panax Notoginseng - voidQSort (int*arr,intLowintHigh ) the { + intpivot; A if(low<High ) the { +Pivot =Partition (arr,low,high); -QSort (arr,low,pivot-1); $QSort (arr,pivot+1, high); $ } - } - voidQuickSort (int*arr,intLowintHigh ) the { - QSort (arr,low,high);Wuyi } the - voidSwap_a (int*arr,intIintj) Wu { - intTMP = * (arr+i); About* (arr+i) = * (arr+j); $* (ARR+J) =tmp; -}
"Big Talk data Structure" Reading notes--9.9 Quick sort