C语言课程设计报告学生宿舍管理系统方案_第1页
C语言课程设计报告学生宿舍管理系统方案_第2页
C语言课程设计报告学生宿舍管理系统方案_第3页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

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

文档简介

1、咼级语言程序设计课程设计说明书设计题目:学生宿舍管理系统、总体设计 31 程序的总体设计 32. 函数原型声明 3二、用户说明 41、菜单界面 52、入住登记界面 53、删除界面 54、浏览界面 65、查询修改 66、排序界面 67、退出 6三、小结 7四、参考文献 7五、源程序代码 7、总体设计1 程序的总体设计确定界面,使用户可选择操作项目(录入,删除,浏览,修改,查询,排序)录入:使用结构体,要求用户输入楼栋、房号、面积、可住人数、已住人数删除:按房号删除以上信息查询:按房号查询以上信息修改:按房号修改以上信息排序:按已住人数排序信息2. 函数原型声明struct room *add(s

2、truct room *head);/添加函数struct room *del(struct room *h);/删除函数void show(struct room *h);/信息浏览函数void serh(struct room *h);/查询与修改函数struct room *sort(struct room *head);/排序函数void can();/ 结束函数开始、用户使用说明运行程序后即可按提示模仿以上操作进行。-IP X|-二r-47理面 貫 舍单 宿菜 I1 使车 迎目记息憂人统 尝蓿浏修住系 住<出-A测唱遁2-3:-4,5.仪1、菜单界面(315噪理设计Debugs

3、生宿舍管理驍总口"肘2、入住登记界面请输入要登记驹入房数:数分 人格 住空 入用 己据住刁>賈顺信面定4住皈43、删除界面请选择服务项目! 备输入退房房号刪除成功!是否返13菜单界面进行其他操作? C1/0)4、浏览界面楼号房号面积所容纳人数己人住人数72021211?2011222是杏返回栗单界面逬行耳他援f乍? (1/0)5、查询修改埼输入要查找的馬号=22查询结果如下:楼号黔号面积 所容纳人数己人住人数72&21211扣需修改请选择丄,按其他任蕙键返回栗单界面 备对入住信息it行修改(技顺序输入)7 202 12 S 5_6、排序界面7201122是否返回菜单界面

4、曲厅其他操作Y7、退出请选择服务项目丨上迎再次使用学生宿舍管理系统!再见*Press any key to continueH三、小结通过编写该程序,熟悉了 C语言的基本语法,选择,循环等结构,深入练习 了函数的调用方法,和文件的读写方法,熟悉了结构体的使用,更加深化了面向 过程语言思想,和一些基本算法。通过对程序的后期调试,熟悉了 C常见错误,锻炼了思维的严密性,和完 备性。通过对程序的注释和画流程图,形成了一套自己编程的风格,和清晰地思 路,使思维更加条理化,清晰化。四、参考文献1 谭浩强.C程序设计(第二版):清华大学,19992 邓文新宏烈.工业大学3 百度五、附件源程序代码#in c

5、lude<stdio.h>#in clude<malloc.h>#in clude<stri ng.h>#in clude <stdlib.h>struct roomint Lnum;int Fnum;int squa;int max num;int innum;struct room *next;struct room *add(struct room *head);/ 添加函数struct room *del(struct room *h);/ 删除函数 void show(struct room *h);/ 信息浏览函数 void serh

6、(struct room *h);/ 查询与修改函数 struct room *sort(struct room *head);/ 排序函数 / 修改点 void can();/ 结束函数void main()struct room *head;int x,y;head=(struct room *)malloc(sizeof(struct room); head->next=NULL;printf(" 欢迎使用学生宿舍管理系统! n");printf(" 按回车键进入菜单界面 n"); getchar();while(1)A:printf(&qu

7、ot;n");printf("|n");printf("|1.入住登记|n");printf("|2.删除信息|n");printf("|3.信息浏览|n");printf("|4.查询修改|n");printf("|6.退出系统|n");printf("|n");printf("n");printf(" 请选择服务项目! n");flushall();scanf("%d",&x

8、);/ 菜单选择if(head->next=NULL&&x!=1&&x!=6)printf(" 系统中无入住信息,请先进行入房登记! n");goto A;switch(x)case 1:head=add(head);system("cls");printf(" 登记完毕! n");continue;case 2:head=del(head);T: scanf("%d",&y);while(y!=1&&y!=0)printf(" 输入错误!请重

9、新输入! n");goto T;if(y=1) system("cls");continue;elsecan(); goto N;1/0)n");case 3: show(head);printf(" 是否返回菜单界面进行其他操作?(J: scanf("%d",&y);while(y!=1&&y!=0)printf(" 输入错误!请重新输入! n"); goto J; if(y=1) system("cls");continue; elsecan();goto

10、N;case 4: serh(head); system("cls"); continue;case 5:1/0)n");head=sort(head); 修改点printf(" 是否返回菜单界面进行其他操作?(scanf("%d",&y);while(y!=1&&y!=0)printf(" 输入错误!请重新输入! n"); goto J;if(y=1)system("cls");continue;elsecan();goto N;continue;case 6:can(

11、);goto Q;default:printf(" 输入错误!请重新输入! n");N:if(y=0)break;Q:if(x=6)break;struct room *add(struct room *head)/ 入住登记struct room *h,*p;int i=0,n;h=head;printf(" 请输入要登记的入房数: n");scanf("%d",&n);printf(" 请输入入住信息: n 楼号 房号 面积 最大入住人数 已入住人数 n");printf(" 数据须按规定顺序

12、输入,不同数据用空格分开。 n");for(i=0;i<n;i+)p=(struct room*)malloc(sizeof(struct room);flushall();scanf("%d%d%d%d%d",&p->Lnum,&p->Fnum,&p->squa,&p->maxnum,&p->innum); p->next=h->next;h->next=p;return h;struct room *del(struct room *h)/ 退房登记 int x;st

13、ruct room *p,*q;p=h->next;q=h;printf(" 请输入退房房号: n"); scanf("%d",&x);if(p=NULL)printf(" 不存在此入房登记! n 是否返回菜单界面进行其他操作?( 1/0) ");elsewhile(p)if(p->Fnum=x)q->next=p->next;free(p);printf(" 删除成功!是否返回菜单界面进行其他操作?(1/0) n");goto K;elseq=p; p=p->next;if(

14、p=NULL)printf(" 不存在此入房登记! n 是否返回菜单界面进行其他操作? ( 1/0)n"); K:return h;return h;void show(struct room *h)struct room *p; p=h->next;if(p=NULL)printf(" 无信息可显示! n");elseprintf("n 楼号 房号 面积 所容纳人数 已入住人数 nn"); while(p)printf("%-7d%-7d%-8d%-13d%-8dn",p->Lnum,p->Fn

15、um,p->squa,p->maxnum,p->innum); p=p->next;void serh(struct room *h)/ 入住信息查询与修改 struct room *p;int x,y,z;p=h->next;H: printf(" 请输入要查找的房号: n"); scanf("%d",&z);while(p->Fnum!=z)p=p->next;if(p=NULL)break;if(p=NULL)printf(" 您所查询的房间号无人入住!是否继续查找?(1/0) n&quo

16、t;);Z: scanf("%d",&x);while(x!=1&&x!=0)printf(" 输入错误!请重新输入! n");goto Z;if(x=1)goto H;elseprintf(" 查询结果如下: n");printf("n 楼号 房号 面积 所容纳人数 已入住人数 nn");printf("%-7d%-7d%-8d%-13d%-8dn",p->Lnum,p->Fnum,p->squa,p->maxnum,p->innum);p

17、rintf(" 如需修改请选择 1,按其他任意键返回菜单界面 n"); scanf("%d",&y);if(y=1)printf(" 请对入住信息进行修改(按顺序输入) n");scanf("%d%d%d%d%d",&p->Lnum,&p->Fnum,&p->squa,&p->maxnum,&p->innum);printf(" 修改成功!修改结果如下:n");printf("n 楼号 房号 面积所容纳人数已

18、入住人数 nn");printf("%-7d%-7d%-8d%-13d%-8dn",p->Lnum,p->Fnum,p->squa,p->maxnum,p->innum); struct room *sort(struct room *h)/ 修改点struct room *p1,*p2,*t,*temp,*q; /* 定义临时指针 */temp=h->next; /* 将原表的头指针所指的下一个结点作头指针 */ h->next=NULL; /* 第一个结点为新表的头结点 */ while(temp!=NULL) /* 当原表不为空时,进行排序 */t=temp; /* 取原表的头结点 */temp=temp->next; /* 原表头结点指针后移 */p仁h; /*设定移动指针pl,从

温馨提示

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

评论

0/150

提交评论