1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
void fnMerge(long a[], int low, int high, int mid);
void msort(long int a[], int m, int n){
if( (n-m)==1)
return;
else{
msort(a, 0, n/2);
msort(a, n/2 +1, n);
fnMerge(a, m, n, n/2);
}
...
void fnMerge(long a[], int low, int high, int mid)
{
int i=0, j=0, k=0;
long c[sizeof(a)];
while(i<=mid && j<high )
{
if(a[i]<=a[j])
c[k++]=a[i++];
else{
c[k++]=a[j++];
}
}
}
|