源代码如下:
// quicksort.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#define max 100
int w;
double *split(double A[],int s,int t){
double x = A[s],temp;
int i;
i=s;
for(int j=s+1;j<=t;j++){
if(A[j]
i++;
if(i!=j){
temp=A[i];
A[i]=A[j];
A[j]=temp;
}
}
}
w = i;
temp=A[i];
A[i]=A[s];
A[s]=temp;
return A;
}
double *quicksort(double A[],int n,int m)
{
double *p=NULL,*p1=NULL,*p2=NULL;
if(n
p=split(A,n,m);
p1 = quicksort(p,n,w-1);
p2 = quicksort(p,w+1,m);
}
return A;
}
int _tmain(int argc, _TCHAR* argv[])
{
double A[max],*p;
int n,i,j;
printf("请输入带排序数组大小:");
scanf_s("%d\n",&n);
for(i=0;i
scanf_s("%f",&A[i]);
fflush(stdin);}
p = quicksort(A,0,n-1);
for(j=0;j
//printf("tttt");
printf("%f\n",A[j]);
}
system("pause");
return 0;
}