#include <stdio.h>#include<stdlib.h>voidSwapint*PI,int*PJ)//Exchanging Data{ inttemp = *Pi; *PI = *PJ; *PJ =temp;}voidShowint*p,intN//Show Array Status{printf ("\ n This state"); for(inti =0; I < n; i++) {printf ("%4d", P[i]); }}voidQuickint*arr,intILeft,intiright) { inti = ILeft;//start looping from the left intj = IRight +1;//start the loop from the right if(I < J)//If the left is less than the right { Do { Do{i++; } while(Arr[i] <= Arr[ileft] && i <iright); //find the first number greater than arr[ileft] from left to right Do{J--; } while(Arr[j] >= Arr[ileft] && j>ileft); //find the first number less than arr[ileft] from right to left//swap if the position of the large number is less than the decimal place if(I <j) {Swap (&arr[i], &Arr[j]); } //The goal of this step is to put the big numbers on the right .} while(I < J);//has been circulating to the i>=j description has already been divided into a good time J save is less than Arr[ileft] the number so to and Arr[ileft] ExchangeSwap (&arr[ileft), &Arr[j]); //J is the dividing point, the quick sort on the left and the rightQuick (arr, ILeft, J-1); Quick (arr, J+1, IRight); }}voidMain () {intnum[Ten] = {Ten,9, -, +,1,8,9, A,0, the }; Quick (num,0,9); Show (num,Ten); System ("Pause");}
Quick Sort Method