- 2
- 0
- 约1.58千字
- 约 3页
- 2019-07-12 发布于江苏
- 举报
归并排序
详细设计
#include stdio.h
#include stdlib.h
#include time.h
#define Max_Size 500
typedef int KeyType;
typedef int OtherType;
typedef struct
{
KeyType key;
OtherType other_data;
}RecordType;
void Merge(RecordType r1[], int low, int mid, int high, RecordType r2[])
/* 已知 r1[low..mid] 和 r1[mid+1..high] 分别按关键字有序排列,
将它们合并成一个有序序列,存放在 r2[low..high] */
{
int j,k;
for(j=mid+1,k=low;low=mid j=high;++k)//
将
ri
中的纪律由小到大的并入
r2
中
{
if(r1[low].key=r1[j].key)
r2[k]=r1[low++];
else
r2[k]=r1[j++];
}
while(low=mid) //
将剩余的
ri[low..mid]
复制到
r2
中
r2[k++]=r1[low++];
while(j=high)
r2[k++]=r1[j+
原创力文档

文档评论(0)