欢迎来到天天文库
浏览记录
ID:42388432
大小:634.07 KB
页数:19页
时间:2019-09-14
《《数据结构》内排序算法》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、《数据结构》课程设计报告设计题目内排序算法学院名称专业班级姓名目录一.实验题目1内排序算法1二・问题描述1三、设计目标1四・需求分析1五.概要设计六、函数2流程图3七、测试分析4八・使用说明7九、课程设计总结8附录(各功能函数源代码)9一、实验题目内排序算法二、问题描述要求从外部文件读入或直接输入数据,编写一程序,通过插入、选择、交换、归并、基数等方法进行数据的排序。三、设计目标设计一个程序,利用内排序各算法,如直接插入、希尔、冒泡、直接接择、基数、归并、堆排序等算法进行数据排序,输出每趟排序结杲,让排序算法更加明了,大大提高排序效率,缩短时间的花费。需求分析本次试验主要分为以下四大功能模块
2、:1)头文件:定义全局变量,申明函数;2)菜单:各排序算法的分类;3)算法:对不同算法的描述定义;4)主函数:定义局部变量,调用各函数。五、概要设计1、各个模块功能的详细描述voidinsetsort(intb[],intn);//直接插入voidsheelsort(intb[],intn);//希尔排序voidbinarysotr(intb[],intn);//折半插入排序voidselectsort(intb[],intn);//简单选择排序voidheapsort(intb[],intn);//堆排序(完全二叉树)voidbubblesort(intb[],intn);//冒泡排序vo
3、idquicksort(intb[],intlow,inthigh);//快速排序voidMerge(inta[],intlow,intmid,inthigh,intb[]);//归并排序voidjishu(intb[],intn);//基数排序2、系统结构功能图六、函数1、头文件3、a."h.h"#include#include#include#include#include^defineNlOOOOintg_flag:b>“head.h”#include#include4、h>#include#include#include^defineMaxKeyNum12//最大关键字个数defineRadix10//关键字的基数^defineMaxSizc80//元索的个数typedefintKeyType://关键字类型为int型typedefstruct{charkey[MaxKeyNum]:intnext;}SListCel1;〃每个元索的关键字类型lypcdcfstruct{SListCel1data[MaxSize]:intkeynum,len://关键字的个数及静态链农的长度}SList;//静态链表类5、型typedefintaddr[Radix];//定义静态指针数组类型typedefstruct{KeyTypekey;}DataType;//元索类型*/SListL;DataTypea[MaxKeyNum];2、主函数ftincludez,h.h"ttinclude^fp・c"#includeFudex・c"#include"Radtlinclude^sort1.c"voidmain(){intg_flag;intb[N],n;charch;ixsort・c"g_flag=0;n=reaDala(b);systemCmodecon:cols=170");//调整屏幕显示大小列、行whil6、ed){switch(numcO){ch=getchar();case1:{{switch(insetr_mu())case'a:insetsort(b,n);printl)ata(b,n);system("pause");break:case'b‘:sheelsort(b,n)://希尔排序//123break;case'c‘:binarysotr(b,n);//折半插入排序break;}break;}case2:{switch(sele_mu())case'1:selectsort(b,n);〃简单选择排序//123pi'intData(b,n);systemC'pause^);brea7、k:case'k':heapsort(b,n);//堆推序(完全二叉树)//123break;}break;case3:{switch(change_mu0)case':bubblesort(b,n);//W泡排序printl)ata(b,n);system(^pause^);break;case'y':quicksort(b,0,n-1)://快速排序break:}break;case4:McrgcSort
4、h>#include#include#include^defineMaxKeyNum12//最大关键字个数defineRadix10//关键字的基数^defineMaxSizc80//元索的个数typedefintKeyType://关键字类型为int型typedefstruct{charkey[MaxKeyNum]:intnext;}SListCel1;〃每个元索的关键字类型lypcdcfstruct{SListCel1data[MaxSize]:intkeynum,len://关键字的个数及静态链农的长度}SList;//静态链表类
5、型typedefintaddr[Radix];//定义静态指针数组类型typedefstruct{KeyTypekey;}DataType;//元索类型*/SListL;DataTypea[MaxKeyNum];2、主函数ftincludez,h.h"ttinclude^fp・c"#includeFudex・c"#include"Radtlinclude^sort1.c"voidmain(){intg_flag;intb[N],n;charch;ixsort・c"g_flag=0;n=reaDala(b);systemCmodecon:cols=170");//调整屏幕显示大小列、行whil
6、ed){switch(numcO){ch=getchar();case1:{{switch(insetr_mu())case'a:insetsort(b,n);printl)ata(b,n);system("pause");break:case'b‘:sheelsort(b,n)://希尔排序//123break;case'c‘:binarysotr(b,n);//折半插入排序break;}break;}case2:{switch(sele_mu())case'1:selectsort(b,n);〃简单选择排序//123pi'intData(b,n);systemC'pause^);brea
7、k:case'k':heapsort(b,n);//堆推序(完全二叉树)//123break;}break;case3:{switch(change_mu0)case':bubblesort(b,n);//W泡排序printl)ata(b,n);system(^pause^);break;case'y':quicksort(b,0,n-1)://快速排序break:}break;case4:McrgcSort
此文档下载收益归作者所有