答:(1)归并排序算法 #include #include using namespace std; void merge(int *data, int p, int q, int r) { int n1, n2, i, j, k; int *left=NULL, *right=NULL; n1 = q-p+1; n2 = r-q; left = (int *)malloc(sizeof(int)*(n1)); right = (int *)malloc(sizeof(int)*(n2)); for(i=0; i>n; input = (int *)malloc(sizeof(int)*(n)); cout<<"请对数组赋值: "; for(int i=0; i>input[i]; } //处理数据 clock_t start,finish; double totaltime; start=clock(); ////开始统计时间 mergeSort(input,0,n-1); //输出结果 for(i=0; i #include using namespace std; void Qsort(int a[],int low,int high) { if(low>=high) { return; } int first=low; int last=high; int key=a[first];/*用字表的第一个记录作为枢轴*/ while(first