为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

归并排序

2017-09-21 3页 doc 12KB 5阅读

用户头像

is_574951

暂无简介

举报
归并排序归并排序 #include #include #include #define Max_Size 5000 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..mi...
归并排序
归并排序 #include #include #include #define Max_Size 5000 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] */ { ; } /* Merge */ void MSort(RecordType r1[], int low, int high, RecordType r3[]) /* r1[low..high]经过排序后放在r3[low..high]中,r2[low..high]为辅助空间 */ { ; } /* MSort */ void MergeSort ( RecordType r[], int n ) /* 对数组r[1..n]做归并排序 */ { MSort ( r, 1, n, r ); } void main() { int i; RecordType r[Max_Size]; int len; printf("请输入待排序记录的长度:"); scanf("%d",&len); srand((unsigned)time(NULL)); for(i=1;i<=len;i++) { r[i].key =rand(); } printf("\n待排序记录:\n"); for(i=1;i<=len;i++) printf("%6d ",r[i].key); printf("\n"); MergeSort(r,len); printf("\n排序后的记录:\n"); for(i=1;i<=len;i++) printf("%6d ",r[i].key); printf("\n"); }
/
本文档为【归并排序】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索