//06.12.22
//Author:Guo R.H
// USTC
// 归并排序
#include
#include
#define N 500
void MergeSort(int a[], int b[], int s, int t)
{
int m,tr[N];
if(s == t)
b[s] = a[s];
else
{
m = (s+t)/2;
MergeSort(a,tr,s,m);
MergeSort(a,tr,m+1,t);
Merge(tr,b,s,m,t);
}
}
int main()
{
int i,a[N],b[N];
for(i=0;i {
a[i] = rand()%100;
printf("%d ",a[i]);
}
printf("\n");
MergeSort(a,b,0,N-1);
for(i=0;i printf("%d ",b[i]);
return 0;
}
阅读(1232) | 评论(0) | 转发(0) |