// xiantree.cpp : Defines the entry point for the console application.
//
#include “stdafx.h”
int Part(int sorce[], int low, int high)
{
int temp = sorce[low];
int inL = low;
int inH = high;
while (inH > inL)
{
while(inH > inL && sorce[inH]
>= temp) inH–;//注意要等号!
sorce[inL] = sorce[inH];
while (inH > inL && sorce[inL]
<= temp) inL++;
sorce[inH] = sorce[inL];
}
sorce[inL] = temp;
return inL;
}
void QuickSort(int sorce[],int low,int high)
{
int mid;
if (low < high)
{
mid = Part(sorce, low, high);
QuickSort(sorce, low, mid-1);
QuickSort(sorce, mid+1, high);
}
else
{
return;
}
}
int main(int argc, char* argv[])
{
int a[3]={3,2,1};
QuickSort(a,0,2);
for (int i = 0;i<12;i++)
{
printf(“%d “,a[i]);
}
printf(“\n”);
printf(“Hello World!\n”);
return 0;
}