Quick Sort
Ideas:
An array, arbitrarily choose a base, bigger than it put his right side, smaller than it put it to the left, a round down divided into two groups, the two groups were again according to the method recursion.
Specific operation:
An array, the first one to do the cardinality out to exist in a variable, set two cursors to begin and end the array, respectively,
Start loop:
Select a and cardinal ratio by the cursor from right to left first, the number is larger than the base of the end of the cursor to the left one bit, smaller than the base of the number is placed on the start of the cursor, and then follow the cursor from left to right to select a number and the base ratio, the number is smaller than the cardinality of the beginning of the cursor to the right one bit, larger than the base on the number of , and then start the cycle anew.
Until two cursors are equal, start recursion.
intMain () {intData[] = { the, $, A, +, the,5, +,Ten,3, -}, K; intlen=sizeof(data)/sizeof(int); QuickSort (data,0, len-1); for(inti =0; i < Len; i++) {cout<<data[i]<<"\ n"; }}voidQuickSort (intArray[],intBegin,intend) { if(begin<end) { intL = begin, R = end, x =Array[begin]; while(L <R) { while(L<r && array[r]>=x) R--; if(l<R) {Array[l]=Array[r]; L++; } while(L<r && array[l]<x) L++; if(l<R) {Array[r]=Array[l]; R--; }} Array[l]= Array[r] =x; QuickSort (array, begin, R-1); QuickSort (Array, R+1, end); }}
Fast sequencing of C + + algorithms