C语言客房管理系统_第1页
C语言客房管理系统_第2页
C语言客房管理系统_第3页
C语言客房管理系统_第4页
C语言客房管理系统_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

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

文档简介

1、客房管理系统1. 题目与要求:客房管理系统系统包括新用户登记功能,统计功能,查询功能,修改功能。1.1问题提出与要求:建立如下结构体:Struct ClientChar Name20;int Sex;int Age;char ID-card ; /*居民身份证*/ int year ;int month;int date; ;Struct HotelInt Room-ID; /*房间号*/Int Tel;int Price;bool sign; /*标记房间是否为空房间*/Struct Client Client-list; /*实现两结构体的嵌套*/ RoomNUM 需求分析根据题目要求,客

2、房信息要用文件存储,提供文件的输入输出操作;在程序中需要对客房具有登记,统计,查询和修改的功能;另外还要用键盘式菜单实现功能选择.2.功能实现设计:2.1总体设计:下面来分析一下整个系统,根据上面的要求分析,可将这个系统设计为五大模块(见下图):注册模块,统计模块,查询模块,修改模块,退出模块。其主要功能为:注册,统计,查询,修改功能。客房管理系统 系统系统 注册统计 查询修改退出2.2详细设计: 主函数主函数一般设计得比较简洁,提供输入,功能处理和输出部分的函数调用。其中各功能模块用菜单方式选择。流程图显示一系列功能选项输入n,判断n是否是?根据n的值调用各功能模块函数结束开始NY程序voi

3、d main() /*主函数*/ int n,w=1; /*变量n保存选择菜单数字,w判断输入的数字是否在功能菜单对应的数字范围之内*/ struct Hotel *info; while(w)puts("tt C语言课程设计 客房管理系统 n");puts("tt 072084班 丁超 学号:20081003552n");puts("tt*n");puts("tt*MENU*n");puts("tt*1 registration*n"); /*注册*/ puts("tt*2stati

4、stic*n"); /*统计*/ puts("tt*3search*n"); /*查询*/ puts("tt*4modify *n"); /*修改*/ puts("tt*5exit*n"); /*退出*/ puts("tt*n"); puts("tt*n"); printf("Choice your number(1-5):bb"); scanf("%d",&n); if(n<1|n>5) /*对选择的数字作判断*/ w=1;

5、 getchar(); switch(n) case 1:regi();break; /*注册模块*/ case 2:stat();break; /*统计模块*/ case 3:search();break; /*查询模块*/ case 4:modify();break; /*修改模块*/ case5:tuichu();break; /*退出模块 */ default: break; getchar(); 功能模块设计.1 注册模块 单独看各数据信息,身份证号码均是字符型,可采用字符型数组;用户在填完个人信息,即可进行房间预定。流程图用户输入信息i!=o吗? 保存调用函数 返回开始NY返回主菜

6、单程序regi() /*注册模块*/ int i,n; struct Hotel *info; char s10; char a10="have" printf(" people number:n"); scanf("%d",&n); for(i=0;i<n;i+) info=(struct Hotel*)malloc(sizeof(RoomNUM); if(info=0) printf(" memroy used overn"); inputs(" t Room_ID:n",in

7、fo->Room_ID,10); if(!(char*)(info->Room_ID)0) break; inputs(" t have people put have nopeople put nulln",info->person,10); if(strcmp(a,info->person) inputs("t name:n",info->Client_list.Name,20); inputs("t sex:n",info->Client_list.Sex,10); inputs("

8、t age:n",info->Client_list.Age,10); inputs("t Id_card:n",info->Client_list.ID_card,20); inputs("t year:n",info->Client_list.year,10); inputs("t month:n",info->Client_list.month,10); inputs("t date:n",info->Client_list.date,10); inputs("

9、;t Tel:n",info->Tel,10); inputs("t Price:n",info->Price,10); printf("t registration donen"); start=dls_store(info,start); inputs(char *prompt, char *s,int count) char p255; do printf("%s",prompt); scanf("%s",p); if(strlen(p)>count) printf("

10、too long!n "); while(strlen(p)>count); strcpy(s,p); struct Hotel *dls_store(struct Hotel *i,struct Hotel *top) static struct Hotel *last=0; struct Hotel *old,*p; if(last=NULL) i->next=NULL; i->prior=NULL; last=i; return i; p=top; old=NULL; while(p) if(strcmp(p->Room_ID,i->Room_ID

11、)<0) old=p; p=p->next; else if(p->prior) p->prior->next=i; i->next=p; p->prior=i; return top; i->next=p; i->prior=0; p->prior=i; return i; old->next=i; i->next=0; i->prior=old; last=i; return start; 统计模块有两种数据进行统计,被占用的房间和未被占用的房间。流程图统计对象 统计合适房间统计被占用房间统计未被

12、占用房间程序stat() /*统计模块*/ struct Hotel *info; char a10="null" char b10="have" int c,count=0; printf("t statistic the used Room_ID put 1, the unused Room_ID put 2 n"); scanf("%d",&c); if(c=1) info=start; while(info) if(!strcmp(a,info->person) printf("Ro

13、om_ID %s n",info->Room_ID); count+; info=info->next; printf("t used rooms are%sn",count); /*统计被占用的房间*/ if(c=2) info=start; while(info) if(!strcmp(b,info->person) printf("t Room_ID %s n",info->Room_ID); count+; info=info->next; printf("t unused rooms are%s

14、n",count); /*统计未被占用的房间*/ display(struct Hotel *info) printf("tt name:%sn",info->Client_list.Name); printf("tt sex:%sn",info->Client_list.Sex); printf("tt age:%sn",info->Client_list.Age); printf("tt Id_card:%sn",info->Client_list.ID_card); prin

15、tf("tt year:%sn",info->Client_list.year); printf("tt month:%sn",info->Client_list.month); printf("tt date:%sn",info->Client_list.date); printf("tt Tel:%sn",info->Tel); printf("tt Price:%sn",info->Price); printf("n");

16、查询模块查询通常可细分为分类查找,此题中分为合适查找,被占用查找,未被占用查找。再与统计信息进行对应,显示对应数据,则用户即可知道合适房间。程序 search() /*查询模块*/ int b; printf(" t search the fixed room put 1n"); printf(" t search the used room put 2n"); printf(" t search the unused room put 3n"); printf(" t back to the main menu put 4

17、n"); do scanf("%d",&b); switch(b) case 1: search1();break; case 2: search2();break; case 3: search3();break; case 4: return; while(b<1|b>4); struct Hotel *find(char *Room_ID) struct Hotel *info; info=start; while(info) if(!strcmp(Room_ID,info->Room_ID) return info; info=i

18、nfo->next; printf(" t can't findn"); return (NULL); search1() char Room_ID10; struct Hotel *info; printf(" t put the Room_ID n"); scanf("%s",Room_ID); getchar(); info=find(Room_ID); if(!info) printf(" t can't findn"); else display(info); search2() s

19、truct Hotel *info; char a10="null" info=start; while(info) if(!strcmp(info->person,a) display(info); printf("n"); info=info->next; search3() struct Hotel *info; char b10="have" info=start; while(info) if(!strcmp(b,info->person) display(info); printf(" n &q

20、uot;); info=info->next; save() register int t,size; struct Hotel *info; char *p; FILE *fp; if(fp=fopen("mlist","wb")=0) printf(" t file can't openn"); exit(0); printf("t savingn"); size=sizeof(RoomNUM); info=start; while(info) p=(char*)info; for(t=0;t&l

21、t;size;+t) putc(*p+,fp); info=info->next; putc(EOF,fp); fclose(fp); printf("t savedn"); .4修改模块该模块的功能是显示用户要修改的信息。用户输入要修改的信息,根据输入信息查对应选项,并提示用户修改该记录的那部分信息,根据用户的选项修改相应的信息。流程图用户输入要修改的信息i!=o吗? 显示找到的记录调用修改记录 返回开始NY询问用户是否继续修改 提示没有找到对应修改信息 NY程序modify() /*修改模块*/ struct Hotel *info; char Room_ID10

22、; char a10="have" char c10="null" int b,f; printf(" t examine the information 1n"); /*检验信息*/ printf(" t change the information 2n"); /*修改信息*/ printf(" t back to the main menu 3n"); /*返回主菜单*/ scanf("%d",&b); if(b=1)search(); if(b=2) prin

23、tf(" t put the Room_IDn"); scanf("%s",Room_ID); info=find(Room_ID); if(!info)printf("t can't findn"); else display(info);printf("t Change Entry n"); if(!strcmp(a,info->person) inputs("t put null:n",info->person,10); if(!strcmp(c,info->pe

24、rson) inputs("t name:n",info->Client_list.Name,20); inputs("t sex:n",info->Client_list.Sex,10); inputs("t age:n",info->Client_list.Age,10); inputs("t Id_card:n",info->Client_list.ID_card,20); inputs("t year:n",info->Client_list.year,10

25、); inputs("t month:n",info->Client_list.month,10); inputs("t date:n",info->Client_list.date,10); inputs("t Tel:n",info->Tel,10); inputs("t Price:n",info->Price,10); if(b=3) return; 退出模块该模块需要有保存,退出,返回三个操作。程序显示一系列功能选项输入n,判断n是否是3?根据n的值调用各功能模块函

26、数结束开始NY程序tuichu() /*退出模块*/ int d; printf("t suggest you save the message,if save put 1,sure to exit put 2 ,back to main menu put 3n"); scanf("%d",&d); if(d=1) save(); /*保存*/ if(d=2) printf("t Thank you for useing the system!n"); /*退出*/ if(d=3) printf("t backn"); /*返回*/ exit(0); 3. 学习心得在老师的带领下进行了C语言程序实践学习。在短短一周的实习期间使我获取了不少新知识也巩固了许多老知识。在这之前,我们已经对C语言这门课程学习了一个学期,对其有了一定的了解,但是也仅仅是停留在学习了解的范围,对

温馨提示

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

评论

0/150

提交评论