归并排序

最后更新于:2022-04-01 20:30:47

                        ~~~

void merge(int *a,int p,int q,int r){ int n1 = q-p+1; int n2 = r-q; int *m = new int[n1]; int *n = new int[n2]; for(int i=0;i<n1;i++) m[i]="a[p+i];" for(int="" j="0;j<n2;j++)" n[j]="a[q+j+1];" int="" i="0,j=0,k=p;" while(i<n1&&j<n2){="" if(m[i]<="n[j])" a[k++]="m[i++];" else="" }="" while(i<n1)="" while(j<n2)="" delete[]="" m,n;="" void="" mergesort(int="" *a,int="" p,int="" r){="" if(p<r){="" q="(p+r)/2;" mergesort(a,p,q);="" mergesort(a,q+1,r);="" merge(a,p,q,r);="" ~~~="" <="" div=""> </n1;i++)>