数据结构课程设计报告学生宿舍管理系统_第1页
数据结构课程设计报告学生宿舍管理系统_第2页
数据结构课程设计报告学生宿舍管理系统_第3页
数据结构课程设计报告学生宿舍管理系统_第4页
数据结构课程设计报告学生宿舍管理系统_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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

30、();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(学号 姓名 性别 生日(年_月_日) 系别 专业 楼号 宿舍号 床号nn); printf(%-8d%-8s%-4c%-6d%-5d%-8d%-12s%-8s%

31、-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); break; p=p-next; if(p=null) printf(ttnot find !); printf(t 继续 ?y/n); ch=getch(); while(ch=y | ch=y); void dorm_search(stu *head) /*按照宿舍信息查找*/ int build_nu

32、m,room_num,bed_num; stu *p; char ch; p=head-next; do system(cls); printf(nn-请输入要查找的学生宿舍信息(楼号 宿舍 床号) : ); printf(nntt 楼号 :); scanf(%d,&build_num); printf(nntt 宿舍号 :); scanf(%d,&room_num); printf(nntt 床号 :); scanf(%d,&bed_num); while(p!=null) if(p-dorm.build_num=build_num & p-dorm.room_num=room_num &p

33、-dorm.bed_num=bed_num)printf(学号 姓名 性别 生日(年_月_日) 系别 专业 楼号 宿舍号 床号nn); printf(%-8d%-8s%-4c%-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); break; p=p-next; if(p=null) printf(ttnot find

34、 !); printf(tt继续 ?y/n); ch=getch(); while(ch=y | ch=y);void search(void) /*查找学生信息*/ int choose; stu *head; initstu(&head); read_from_file(head); system(cls); flushall();printf(n*欢迎进入学生宿舍管理系统*nnnn); printf(nntt1.根据宿舍信息查找.); printf(nntt2.根据学生学号查找.); printf(nntt3.退出.nn); printf(n请选择查找方式:); scanf(%d,&ch

35、oose); switch(choose) case 1: dorm_search(head); break;case 2:stuinfo_search(head);break; case 3: break; void sort_in_num(void) /*将学生信息按学号排序*/ stu *head; stu *i,*j,*k; stu *m,*n; stu *temp; int l=0; initstu(&head); read_from_file(head); /冒泡排序法 for(m=head,i=head-next;i;m=i,i=i-next) k=i; for(n=i,j=i-next;j;n=j,j=j-next) if(j-numnum) k=j; break; if(i!=k) m-next=j;n-next=i;temp=i-next; i-next=j-next; j-next=temp;i=head; system(cls);printf(nntt*欢迎进入学生宿舍管理系统*nn);printf(nn输入学生信息 : nn); i=head-next; printf(学号 姓名 性别 生日(年_月_日) 系别 专业 楼号 宿舍号 床号nn); while(i) printf(%-8d%-8s%-4c%-6d%

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论