归并排序求指教
不知道哪里错了
#include <iostream>using namespace std;void merge(int d1[],int d2[],int start,int mid,int end){ int i=start,j=mid+1,s=start; while(i<=mid&&j<=end) { if(d1[i]<d1[j]) d2[s++]=d1[i++]; else d2[s++]=d1[j++]; } while(i<=mid) d2[s++]=d1[i++]; while(j<=end) d2[s++]=d1[j++];}void msort(int d1[],int d2[],int start,int end){ if(start==end) d2[start]=d1[start]; else { int mid=(start+end)/2; int *temp=new int[end-start+1]; msort(d1,temp,start,mid); msort(d1,temp,mid+1,end); merge(temp,d2,start,mid,end); delete temp; }}void main(){ int a[8]={3,6,8,2,7,9,4,1}; msort(a,a,0,7); for(int i=0;i<8;i++) printf("%d ",a[i]); printf("\n");}