标签:amp i++ 归并 void let pre class 归并算法 core
1 void MergeSortCore(int *a,int low,int mid,int high) 2 { 3 int *b = new int; 4 int i,j,k; 5 for(i=low,j=mid+1,k=low;i<=mid && j<=high;k++) 6 { 7 if(a[i]<a[j]) 8 b[k] = a[i++]; 9 else 10 b[k] = a[j++]; 11 } 12 for(;i<=mid;i++) 13 b[k++] = a[i]; 14 for(;j<=high;j++) 15 b[k++] = a[j]; 16 for(i=low;i<=high;i++) 17 a[i] = b[i]; 18 delete []b; 19 } 20 21 void MergeSort(int *a,int low,int high) 22 { 23 if(low<high) 24 { 25 int mid = low+(high-low)/2; 26 MergeSort(a,low,mid); 27 MergeSort(a,mid+1,high); 28 MergeSortCore(a,low,mid,high); 29 } 30 }
标签:amp i++ 归并 void let pre class 归并算法 core
原文地址:https://www.cnblogs.com/susidian/p/10013132.html