b[k++] = a[j++]; g++; ++j; } ++k; }
// if(i <= mid) while(i <= mid) { b[k++] = a[i++]; g++; } //else
while(j <= high) { b[k++]=a[j++]; g++; }
}
//进行一趟归并
void MergePass(sqlist a, sqlist b, int n, int lenth) {
int i = 0, k=0;
while(i <= n - 2*lenth) {
Merge(a, b, i, i + lenth -1, i + 2*lenth -1); i += 2*lenth; }
if(i < n - lenth ) {
Merge(a, b, i, i + lenth -1, n-1); } else
for(k = i; k <= n-1; k++) {b[k] = a[k];
g++; } }
//进行二路归并
void MergeSort(sqlist a, int n) {sqlist b;
//int* b=(int*)malloc(n*sizeof(int)); int lenth = 1; while(lenth < n/2+1) {
MergePass(a, b,n, lenth); lenth = 2*lenth; MergePass(b, a, n, lenth); lenth = 2*lenth; }
cout<<\移动次数=\比较次数=\ } //堆排序
void sift(sqlist r,int s,int m) { int j; rec x; x=r[s];
for(j=2*s;j<=m;j*=2) {q++;