还剩17页未读,继续阅读
本资源只提供10页预览,全部文档请下载后查看!喜欢就下载吧,查找使用更方便
文本内容:
实验报告
一、问题陈述及其需求分析
(一)问题陈述学生信息管理系统是对学生信息的基本管理,其中包括以下及模块()增加一个学生的信息(需输入要增加学生的所有信息);1()统计本班学生总人数及男女生人数2()分别按照学号查找学生的信息;若找到则输出该学生全部信息,否则输出查3找不到的提示信息()按学号对所有学生信息排序,并输出结果;4()删除一个学生的信息(需指定要删除学生的学号);同时显示删除后的结果5
(二)功能需求分析学生信息管理系统设计学生信息包括学号,姓名,性别,出生年月,电话使之提供以下功能系统以菜单方式工作
1..建立链表并显示
2.插入新的学生信息
3.删除某学号的学生信息
4.查找某学号的学生信息
5.对学生信息排序
6、统计学生人数
7、输出学生信息8二总体设计
(一)模块依据程序的数据结构,描述该程序的层次结构,如下图.建立链表并显示1()void createliststruct stucode**r;.插入新的学生信息2getchar;getchar;break;case7:outr;printfTesting function7\nPress anykey tocontinued11;getchar;getchar;break;case O:flag=0;printfnThe end.\nn;getchar;getchar;break;default:printfn\nWrong Selection!选择错误,请重选!\n”;getchar;getchar;void createliststruct stucode**r struct stucodelong n;char a
[20];char s|4|;char b
[12];char m
[12];if*r*r=NULL;请输入学号请按学号升序排列姓名性别出生日期电话若要结printf\n\n束请输入五个为零\n;scanfn%ld%s%s%s%sH,n,a,s,b,m;ifn==O return;p=L*mallocsizeofL;p-student.num=n;strcpyp-student.name,a;strcpyp-student.sex,s;strcpyp-student.birthday,b;strcpyp-student.tel,m;p-next=NULL;*r=p;scanfH%ld%s%s%s%sH,n,a,s,b,m;whilent=p;p=L*mallocsizeofL;p-student.num=n;strcpyp-student.name,a;strcpyp-student.sex,s;strcpyp-student.birthday b;9strcpyp-student.tel,m;p-next=NULL;t-next=p;scanf%ld%s%s%s%s,n,a,s,b,m;void searchistruct stucode*rlong x;if!r{没有学生信息可查询!printf\nreturn;请输入要查询的学生信息的学生学号:;printf\nscanfn%ldn x;9whilerr-student.num!=xr=r-next;if r=NULLprintfHError!No suchstudent!\nn;elseprintfH%ld%s%s%s%s\nn,r-student.num,r-student.name,r-student.sex,r-student.birthday,r-student.tel;void search2struct stucode*rint a=0,b=0,c=0;if!r没有学生信息可统计!printf\nreturn;}else{whiler{a++;ifstrcmpr-student.sex,H男==O{b++;}〉女ifstrcmpr-student.sexj==0{c++;}r=r-next;}共有学生%人,其中男生%€人,女生%人”printf d1d,a,b,c;}void delstruct stucode**rlong k;struct stucode*p=*r,*t;if!*r没有学生信息可删除printf!\n;return;请输入要删除的学生信息的学生学号:;%printf\n scanf”ld\k;ifp-student.num-k*r=*r-next,freep;else{whilep-nextp-next-student.num!=kp=p-next;ifp-next==NULLprintfHError!No suchstudent!\nn;else t=p-next;p-next=p-next-next;freet;}void insertstruct stucode**rlong n;char a
[20];char s
[4];char b
[12];char m
[12];L请输入学号请按学号升序排列姓名性别出生日期电话若要结束printff\n\n请输入三个为零\n;scanfn%ld%s%s%s%sn n,a,s,b,m;9p=L*mallocsizeofL;p-student.num=n;strcpyp-student.name,a;strcpyp-student.sex,s;strcpyp-student.birthday,b;strcpyp-student.tel,m;if!*r*r=p;*r-next=NULL;return;ifp-student.num*r-student.nump-next=*r,*r=p;elset=*r;k=t;whilet-nextt-next-student.num=p-student.num t=t-next;p-next=t-next;t-next=p;*r=k;void sortstruct stucode**rstruct stucodeif!r没有学生信息可排序!;printf\nreturn;if!*r||!*r-nextreturn;t=*r;p=t-next;t-next=NULL;q=p-next;ifp-student.numt-student.nump-next=t;;t=p}elsez=t;whilez-nextz-next-student.num=p-student.num z=z-next;p-next=z-next;z-next=p;p=q;}*r=t;void outstruct stucode*rprintfn\n\nn;if!rprintf(没有学生信息可输出!\nn);return;)()while rprintf(n%ld%s%s%s%s\nH,r-student.num,r-student.name,r-student.sex,r-stude)nt.birthday,r-student.tel;r=r-next;}()printf\n\n;)()void menu{(学生信息管理系统)printf\n\n;(菜单)printf\n\n\rT;(建立链表并显示)printf\n1\n;(查找某学号的学生信息)printf\n2\n;(查找某姓名的学生信息)printf\n3\n;(删除某学号的学生信息)printf\n4\n;(插入新的学生信息)printf\n5\n;(按学号降序排列输出);printf\n6\n(输出);printf\n7\n(退出)printf\nO\n;(请选择您要执行的选项:)printf\n\n;)void insertstruct stucode**r;.删除某学号的学生信息3void delstructstucode**r;.查找某学号的学生信息4void searchistructstucode*r;.对学生信息排序5void sortstructstucode**r;.统计学生人数6void search2structstucode*r;、输出学生信息7void outstructstucode*r;二程序总体框架模块层次结构,只确定了模块之间的关系和函数原型,不是程序的执行步骤程序总体框架是该程序的总体流程图改程序不是顺序连续地执行全部功能,而是在某一时刻有选择地执行一种或多种功能因此选用菜单方式是较佳的方案,程序总体框架如下图main菜单1输入2输出3排序4添加5册U
6、统计除查询78退出菜单代码
(三)运行环境(软,硬件环境)硬件内存,主板,硬盘,显卡,键盘,显示器等等CPU,软件应用软件Windows XPtrubo c
(四)开发工具和编程语言开发工具trubo c编程语言:语言C
三、详细设计
(一)数据结构依据给定学生信息和数据格式,数组用结构体实现,结构体层次结构:struct stud(学号整型long intnum;姓名字符串name
[20];性别字符串sex
[2];出生日期字符串birthday
[12];联系方式字符串tel
[12];;头文件#includestdio.h#includestdlib.h#includestring.h/*定义数据结构和链表*/struct studlongnum;char name
[20];char sex
[2];char birthday
[12];char tel
[12];;typedef structstucodestruct studstudent;structstucode*next;;}L
二、算法说明主函数的算法设计
1.清屏、显示子菜单及运用选择操作运用语句,调用各个子函数,最后退swith出程序,主要代码whileflag systemcls;menu;choose=getchar;switchchoose{}.各个子函数的算法设计
2.一些显示操作,输入相应的内容即可1代码.创建链表并显示学生信息2申请空间p=L*mallocsizeofL;学生信息的输入及显示p-student.num=n;strcpyp-student.name,a;p-next=NULL;.学生信息的删除3首先查询要删除的学生信息的学号,如果存在删除该学生,如果不存在给予相应的提示t=p-next;p-next=p-next-next;〃释放空间freet;.学生信息的排序4新建链接,然后按要求对学生信息进行排序whilez-nextz-next-student.num=p-student.numz=z-next;p-next=z-next;z-next=p;.学生人数的统计
5.学生信息的显示:直接发调用函数即可6
四、运行结果
五、总结.调试分析11刚编译完后有好多错误和警告,运行失败,然后经过修改错误警告慢慢减少,最终可以运行()该程序中可能还存在一些小问题,比如有的时候它会主动清屏,有的时候不2会并且我在编译的过程中发现自己存在好多毛病,有粗心了等,不注意细节,其实自己也知道细节决定成败,以后我会注意.设计总结2经过一周的课程设计,我学到了很多东西
①巩固和加深了对数据结构的理解,提高综合运用本课程所学知识的能力
②培养了我选用参考书,查阅手册及文献资料的能力培养独立思考,深入研究,分析问题、解决问题的能力
③过实际编译系统的分析设计、编程调试,掌握应用软件的分析方法和工程设计方法
④够按要求编写课程设计报告书,能正确阐述设计和实验结果,正确绘制系统和程序框图
⑤通过课程设计,培养了我严肃认真的工作作风,逐步建立正确的生产观念、经济观念和全局观念课程设计是把我们所学的理论知识进行系统的总结并应用于实践的良好机会,有利于加强我们用知识理论来分析实际问题的能力,进而加强了我们对知识认识的实践度,巩固了我们的理论知识,深化了对知识的认识,并为走向社会打下一个良好的基础在这次课程设计中我遇到许多问题和麻烦,得到了老师的帮助和指导,才能够使得这次课程设计顺利的进行下去,另外,在程序调试过程中,也得到很多同学的帮助,给我及时指出错误,提出许多宝贵意见在此对老师和同学们表示感谢!
六、参考文献书籍谭浩强《程序设计》(第三版)北京清华大学出版社C谭浩强《程序设计题解与上机指导》(第三版)北京清华大学出版C社王为青刘变红《语言高级编程及实例剖析》人民邮电出版社张建勋《语言程C C序设计教程》清华大学出版社李玲桂玮珍刘莲英《语言程序设计教程习题解答与实验指导》人民邮电出版社C源程序#includestdio.h#includestdlib.h#includestring.hstruct studlongnum;char name
[20];char sex
[2];char birthday
[12];char tel
[12];;typedef structstucode{struct studstudent;structstucode*next;;}L voidmenu;void createliststructstucode**r;void outstructstucode*r;void searchistructstucode*r;void search2structstucode*r;void delstructstucode**r;void insertstructstucode**r;void sortstructstucode**r;void maincharchoose;int flag=l;structstucode*r=NULL;whileflagsystemHclsn;menu;choose=getchar;switchchoose{case T:createlistr;outr;printfHTesting function1\nPress anykey tocontinue\nH;getchar;getchar;break;case2:search lr;printfHTesting functionl\nPress anykey tocontinue\nn;getchar;getchar;break;case3:search2r;printfTesting function1\nPress anykey tocontinue\nH;getchar;getchar;break;case4:delr;outr;printfnTesting functionl\nPress anykey tocontinue/;getchar;getchar;break;case5:insertr;outr;printfTesting function1\nPress anykey tocontinue\nn;getchar;getchar;break;case6:sortr;outr;printfnTesting functionl\nPress anykey tocontinue\nH;。
个人认证
优秀文档
获得点赞 0