C?????????????
???????????? ???????[ 2013/4/19 14:41:54 ] ????????
???????+???????????£??????????????
????????????
#include <stdio.h>
void MERGE(int *A?? int b?? int m?? int e)
{
int l = m-b+1?? r = e-m?? i;
int L[l+1]?? R[r+1];
for(i=0; i< l; i++)
{
L[i] = A[b+i];
}
for (i=0; i< r; i++)
{
R[i] = A[m+i+1];
}
L[l] = 32767;
R[r] = 32767;
l = 0;
r = 0;
for(i=0; i< e-b+1; i++)
{
if(L[l] < R[r])
{
A[b+i] = L[l];
l ++;
}
else {
A[b+i] = R[r];
r ++;
}
}
}
void MERGE_SORT(int *A?? int b?? int e)
{
if(b < e)
{
int m = (b + e) / 2;
MERGE_SORT(A?? b?? m);
MERGE_SORT(A?? m+1?? e);
MERGE(A?? b?? m?? e);
}
}
int main()
{
int A[500];
int lens?? i;
printf("Please Enter the lenghth of array:");
scanf("%d"?? &lens);
printf("Please Enter the elements of the array:");
for(i=0; i< lens; i++)
scanf("%d"?? &A[i]);
MERGE_SORT(A?? 0?? lens-1);
printf("the result of the sort is:
");
for(i=0; i< lens; i++)
{
printf("%d "?? A[i]);
}
return 0;
}
??????
![](/images/ad-banner/ad-banner.png)
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11