写法二: c语言 1#include<stdio.h>2inta[6];3intmain() {4printf("开始快速排序请输出 5个数:");5//快速排序6for(inti =0; i <5; i++) {7scanf_s("%d", &a[i]);8}9qsort(0,4);//4=n-1 n是数组长度10//降序排列11/*for (int i = 5; i>0; i--) {12printf("%5d", a[...
}voidfastsort(intv[],intfirst,intlast){inti, storeindex;voidswap(intv[],inti,intj);if(first >= last)return;//fewer than two eleswap(v, last, (first + last)/2);//move partition elemstoreindex = first;for(i = first; i <= last-1; i++)if(v[i] <= v[last]) {swap(v, s...
分治法快速排序 #include <> #include <> #include <> voidMergeSort(int*data,intx,inty,int*temp) { intp,q,m,i=x; if(y-x>1) { m = x+(y-x)/2; p = x; q = m; MergeSort(data,x,m,temp); MergeSort(data,m,y,temp);...