数据结构课程设计报告学生宿舍管理系统.doc

上传人:仙人指路1688 文档编号:2396817 上传时间:2023-02-17 格式:DOC 页数:26 大小:112KB
返回 下载 相关 举报
数据结构课程设计报告学生宿舍管理系统.doc_第1页
第1页 / 共26页
数据结构课程设计报告学生宿舍管理系统.doc_第2页
第2页 / 共26页
数据结构课程设计报告学生宿舍管理系统.doc_第3页
第3页 / 共26页
数据结构课程设计报告学生宿舍管理系统.doc_第4页
第4页 / 共26页
数据结构课程设计报告学生宿舍管理系统.doc_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《数据结构课程设计报告学生宿舍管理系统.doc》由会员分享,可在线阅读,更多相关《数据结构课程设计报告学生宿舍管理系统.doc(26页珍藏版)》请在三一办公上搜索。

1、西安郵電學院数据结构课程设计报告题 目: 学生宿舍管理系统 系部名称:通信工程系专业名称:通信工程班级:通工0805学 号:学生姓名 :指导教师:时间:2009年12月16日 至2009年12月25日 一、 课程设计目的数据结构课程设计是让学生综合运用数据结构课程中学到的几种典型数据结构,以及程序设计语言(C语言),自行实现一个较为完整的应用系统的设计与开发通过课程设计,使学生通过系统分析、系统设计、编程调试,写实验报告等环节,进一步掌握应用系统设计的方法和步骤,灵活运用并深刻理解典型数据结构在软件开发中的应用 。学会将知识应用于实际的方法,提高分析和解决问题的能力,增加综合能力。二、课程设计

2、内容 用C语言编写“学生宿舍管理系统”,要求如下:1. 创建链表,录入数据。2. 数据的读写操作。3. 数据的更新操作。4. 数据的删除和插入。5. 请你要求对数据进行查找。6. 按要求排序。7. 设计总体菜单界面。三、需求分析1、录入数据 学生的基本信息,包括学号、姓名、性别、年龄(出生年月日)、专业、班级等。 宿舍楼的基本信息,包括宿舍楼号、学生所住的房间号和宿舍床位号等。2、数据存储 信息的录入要求用链表,把输入的信息要求存储到指定文件夹中,以便随时查看,也可供程序调用,方便操作人员不用重复输入数据。3、数据的更新 更新包括插入、删除、修改。 删除分根据学号删除和根据学生的楼层信息删除。

3、5、数据的查询 查询可以根据学号和姓名、宿舍信息不同方面进行查询,方便操作者使用。6、数据的排序 操作者可以使所输入的信息按学号排序。7、数据的统计 分别可以按整体统计,统计所有学生人数,男生人数和女生人数,也可以按宿舍楼号统计,统计一个宿舍楼所有学生人数。四、概要设计1系统结构图(功能模块图)主函数录入存储数据操作输出信息输入统计查找修改删除插入显示排序2功能模块说明: (1). 数据录入:创建单链表,调用Initnode()函数申请头结点,在调用Creat(),在调用Write_to_File()函数将信息写入文件中,(2) 插入模块:先将文件信息读出,再调用Insert()函数,可以向文

4、件中插入 的信息。(3) 插入模块:先将文件信息读出,再调用Del()函数,可以将输入错误或者 需要的信息删除。(4) 修改模块:先将文件信息读出,再调用Modify()函数,将输入错误的信息修改。(5) 查询模块:先将文件信息读出,再调用Search(),在Search()中有调用两个数,一个按照宿舍信息查询Dorm_search(),需要楼号和宿舍号,一个按照生信息查询Stu_search()需要学生学号或者姓名。(6) 排序模块:先将文件信息读出,再调用Sort_in_Num(),按照学生学号排序,拍完续没有直接写入文件,如果要直接写入调用文件读入函数Write_to_File().(7

5、) 统计模块:先将文件信息读出,再调用Stat()函数,统计了女生人数和男生人数,还统计了总人数和男女宿舍个数。五详细过程和运行结果:删除模块 开始 输入要删除学生的学号num 组织循环,扫描存储学生信息的链表 p-num:num != =删除该学生信息结束开始插入模块 选择插入方式头插入学生信息中间插入学生信息输入插入位置(学号num)输入插入的学生信息p-num:num组织循环,扫描存储学生信息的链表 将其入栈,即将插入的学生信息插到了最前面 输入插入学生的信息 = !=将要插入的学生信息插到了学号为num的学生之后、结束查找模块 开始选择查找方式 按宿舍信息查找按学生学号查找组织循环,扫

6、描存储学生信息的链表表输入要查找的学生build_num,room_num,bed_num输入要查找的学生学号nump-build_num:room_nup-room_num:room_nup-bed_num:bed_nump-num:num != != =输出该学生的信息 输出该学生信息 = 结束 开始修改模块输入要修改的学生学号num组织循环,扫描存储学生信息的链表表p-num:num != =修改学生信息结束 开始排序模块 组织循环,扫描存储学生信息的链表表选出学号最小的学生,与第一学生交换存储位置在余下的学生中选出学号最小的学生与第二个学生交换存储位置以此类推,直至排序完成结束开始统计

7、模块 组织循环,扫描存储学生信息的链表表p-sex=mp-sex=fCount2+Count1+Count1%4=0Count1%4=0结束六调试情况,对自己的评价和体会:调试程序真的比想象中麻烦很多,以前只是写一些很简单的代码,更多的是照着书在抄,当出现错误是,我们不知道怎么调试,开始实习时就在计划这做一个如何完美的程序,当我着手去写的时候,我发现平时的知识积累太少了,更本没有思路。看了很多书,有了想法,可是做起来有些功能好难。这次实习,让我觉得C语言不只是你知道他有写什么 ,而要看你自己能用C写出什么,只要写出对的代码,那你就是会了,时间长了自然就能写出很漂亮的代码了。虽然写的程序有了老师

8、的要求,却没有做到自己想要的结果,本来想换一个界面,换一个颜色,可是都没有,基础知识掌握的很流利时时间已经不多了,不过我会再课外的时间,学会如何能让程序变得简洁易懂,让运行结果更漂亮。我想我的C学习不会随想和实习的结束而结束,我喜欢当我运行不正确时安静思考的自己,喜欢当程序该了好多次改好了那种激动的心情,我会继续努力,完善自己,对自己说:加油!在实习过程中也的到了很多人的帮助,在这谢谢我们的指导老师,谢谢我们同学,还有帮我看过代码的学长。七参考文献: C语言程序设计: 王曙燕-科技出版社数据结构使用C语言:陈一华,刘学民,潘道才-电子科技出版社数据结构C语言描述:耿国华-高等教育出版社八附录:

9、源代码(详见电子版报告)#include #include #include #include typedef struct int Year; int Month; int Day;DATE;typedef struct int Build_num; /*楼号*/ int Room_num; /*宿舍号*/ int Bed_num; /*床号*/Dorm;typedef struct Student_information int Num; /*学号*/ char Name15; /*姓名*/ char Sex; /*性别*/ char Department20; /*系别*/ char S

10、ubject20; /*专业*/ DATE Birth; /*出生日期*/ Dorm dorm; struct Student_information *next;Stu;void Write_to_File(Stu *L) /*将信息写入文件*/ FILE *fp; Stu *p; fp=fopen(e:Dorm.txt,w); if(fp=NULL) printf(此文件不能打开,按任意键退出!); getch(); exit(0); p=L-next; while(p) fprintf(fp,%d %s %c %d %d %d %s %s %d %d %dn,p-Num,p-Name,p

11、-Sex, p-Birth.Year,p-Birth.Month,p-Birth.Day,p-Department, p-Subject,p-dorm.Build_num,p-dorm.Room_num,p-dorm.Bed_num); p=p-next; fclose(fp);void InitStu(Stu *h) /*创建头结点*/ (*h)=(Stu *)malloc(sizeof(Stu); if(h=NULL) printf(Init Stu error!); getch(); exit(0); (*h)-next=NULL;void Create(void) /*创建单链表*/

12、Stu *head; Stu *p,*q; char ch; InitStu(&head); q=head; while(1) system(cls);printf(ntt*欢迎进入学生宿舍管理系统*n); printf(nntt*请录入学生信息*nnn);p=(Stu *)malloc(sizeof(Stu); flushall(); printf(nt学号:); scanf(%d,&p-Num); flushall(); printf(nt姓名:); scanf(%s,p-Name); flushall(); printf(nt性别:); scanf(%c,&p-Sex); flushal

13、l(); printf(nt生日(年_月_日):); scanf(%d_%d_%d,&p-Birth.Year,&p-Birth.Month,&p-Birth.Day); flushall(); printf(nt系别:); scanf(%s,p-Department ); flushall(); printf(nt专业:); scanf(%s,p-Subject); flushall(); printf(nt楼号:); scanf(%d,&p-dorm.Build_num); flushall(); printf(nt宿舍号:); scanf(%d,&p-dorm.Room_num); fl

14、ushall(); printf(nt床号:); scanf(%d,&p-dorm.Bed_num); p-next=q-next; q-next=p; q=p; flushall(); printf(nntttEnd with 0?); ch=getch(); if(ch=0) break; Write_to_File(head); void Read_from_File(Stu *h) /*将文件信息读出*/ FILE *fp; Stu *p,*q; int i; fp=fopen(e:Dorm.txt,r); if(fp=NULL) printf(Cannot open the file

15、); exit(0); q=h; while(!feof(fp) p=(Stu *)malloc(sizeof(Stu); i=fscanf(fp,%d %s %c %d %d %d %s %s %d %d %dn,&p-Num,p-Name,&p-Sex, &p-Birth.Year,&p-Birth.Month,&p-Birth.Day,p-Department, p-Subject,&p-dorm.Build_num,&p-dorm.Room_num,&p-dorm.Bed_num); if(i!=11) break; p-next=q-next; q-next=p; q=p; fclo

16、se(fp);int Display() /*将文件信息显示出来 */ Stu *head; Stu *p; InitStu(&head); Read_from_File(head); p=head-next; system(cls); if(!p) printf(Have no element!); printf(nEnd with ESC); getch(); return 0; printf(ntt*欢迎进入学生宿舍管理系统*nnnn); printf(学号 姓名 性别 生日(年_月_日) 系别 专业 楼号 宿舍号 床号nn); while(p) printf(%-8d%-8s%-4c%

17、-6d%-5d%-8d%-12s%-8s%-8d%-8d%-5dn,p-Num,p-Name,p-Sex,p-Birth.Year,p-Birth.Month,p-Birth.Day,p-Department,p-Subject,p-dorm.Build_num,p-dorm.Room_num,p-dorm.Bed_num); p=p-next; printf(nEnd with ECS); getch(); return 1;void Delete() /*删除学生信息*/ Stu *head; Stu *p,*q; char ch,h; int N; int Build_num,Room_

18、num,Bed_num; InitStu(&head); Read_from_File(head); q=head; p=head-next;do system(cls); flushall(); printf(ntt*欢迎进入学生宿舍管理系统*n); printf(nntta. 根据学生学号删除n); printf(nnttb.根据宿舍信息删除n); printf(nntt-请选择删除方式:); ch=getchar(); while(1) if(ch=a) printf(nn-请输入学生学号:); scanf(%d,&N); while(p) if(p-Num=N) q-next=p-ne

19、xt; free(p); p=q-next;printf(删除成功!);break; q=p;p=p-next; if( p=NULL) printf(n*Not find the student!*); break; else if(ch=b) printf(nn-请输入宿舍信息(楼号 宿舍 床号):); scanf(%d %d %d,&Build_num,&Room_num,&Bed_num); while(p!=NULL) if(p-dorm.Build_num=Build_num & p-dorm.Room_num=Room_num & p-dorm.Bed_num) q-next=p

20、-next; free(p); p=q-next; printf(删除成功!); break; q=p;p=p-next; if(p=NULL) printf( Not find the student); break; break;printf(nn*继续 ?Y/N);h=getch();while(h=Y |h=y);Write_to_File(head);void MidInsert() /*中间插入学生信息*/Stu *head; Stu *p,*q; char ch; int N; InitStu(&head); Read_from_File(head); q=head-next;

21、system(cls); printf(ntt*欢迎进入学生宿舍管理系统*n); flushall();doprintf(nnt-请输入插入位置 : );scanf(%d,&N);while(q!=NULL)p=(Stu *)malloc(sizeof(Stu *);if(q-Num=N)printf(tt请输入插入的学生信息 :n ); flushall();printf(t 学号:);scanf(%d,&p-Num); flushall();printf(nt 姓名:); scanf(%s,p-Name); flushall();printf(nt性别:); scanf(%c,&p-Sex

22、); flushall();printf(nt 生日(年_月_日):);scanf(%d_%d_%d,&p-Birth.Year,&p-Birth.Month,&p-Birth.Day); flushall(); printf(nt 系别:);scanf(%s,p-Department); flushall();printf(nt 专业:);scanf(%s,p-Subject); flushall();printf(nt 楼号:);scanf(%d,&p-dorm.Build_num); flushall();printf(nt 宿舍号:);scanf(%d,&p-dorm.Room_num

23、); flushall();printf(nt 床号:);scanf(%d,&p-dorm.Bed_num);p-next=q-next;q-next=p;break;p=q;q=q-next;if(q=NULL)printf(tt Not find !);Write_to_File(head); printf(t 继续 ?Y/N);ch=getch();while(ch=y|ch=Y);Stu *HeadInsert(Stu *top) Stu *p; char ch; InitStu(&top); Read_from_File(top); system(cls); printf(ntt*欢

24、迎进入学生宿舍管理系统*n); flushall(); do p=(Stu*)malloc(sizeof(Stu); p-next=NULL; printf(tt请输入插入的学生信息 :n ); flushall();printf(t 学号:);scanf(%d,&p-Num); flushall();printf(nt 姓名:); scanf(%s,p-Name); flushall();printf(nt性别:); scanf(%c,&p-Sex); flushall();printf(nt 生日(年_月_日):);scanf(%d_%d_%d,&p-Birth.Year,&p-Birth

25、.Month,&p-Birth.Day); flushall(); printf(nt 系别:);scanf(%s,p-Department); flushall();printf(nt 专业:);scanf(%s,p-Subject); flushall();printf(nt 楼号:);scanf(%d,&p-dorm.Build_num); flushall();printf(nt 宿舍号:);scanf(%d,&p-dorm.Room_num); flushall();printf(nt 床号:);scanf(%d,&p-dorm.Bed_num); if (top!=NULL) p-

26、next=top; top=p; else top=p; printf(nn*继续?Y/N); ch=getch();while(ch=y|ch=Y); return(top);void Insert()int choose; Stu *head,*top; InitStu(&head); Read_from_File(head); system(cls); flushall();printf(n*欢迎进入学生宿舍管理系统*nnnn); printf(nntt1.中间插入学生信息.); printf(nntt2.开头插入学生信息.); printf(nntt3.退出.nn); printf(n

27、请选择查找方式:); scanf(%d,&choose); switch(choose) case 1: MidInsert(); break;case 2:HeadInsert(top);break; case 3: break; void Modify(void) /*修改学生信息*/ Stu *head; Stu *p; char ch; int N; InitStu(&head); Read_from_File(head);system(cls);printf(ntt*欢迎进入学生宿舍管理系统*n);printf(nn-请输入修改的学生信息(学号): );scanf(%d,&N);p=

28、head-next;dowhile(p!=NULL)if(p-Num=N)printf(tt请输入新的学生信息 :n );printf(t学号:);scanf(%d,&p-Num); flushall();printf(nt姓名:); scanf(%s,p-Name); flushall();printf(nt性别:); scanf(%c,&p-Sex); flushall();printf(nt生日(年_月_日):);scanf(%d_%d_%d,&p-Birth.Year,&p-Birth.Month,&p-Birth.Day); flushall();printf(nt系别:);scan

29、f(%s,p-Department); flushall();printf(nt专业:);scanf(%s,p-Subject); flushall();printf(nt楼号:);scanf(%d,&p-dorm.Build_num); flushall();printf(nt 宿舍号:);scanf(%d,&p-dorm.Room_num); flushall();printf(nt床号:);scanf(%d,&p-dorm.Bed_num);break;p=p-next;if(p=NULL)printf(tt Not find !); printf(t 继续 ?Y/N);ch=getch();while(ch=y|ch=Y);Write_to_File(head);void StuInfo_search(Stu * head) /*按照学生学号查找*/ int num; Stu *p; char ch; p=head-next ; do system(cls); printf(nn-请输入要查找的学生学号 : ); scanf(%d,&num); while(p!=NULL) if(p-Num=num )printf(学号 姓名 性别 生日(年_月_

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号