




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、一、题目:客房管理系统二、题目要求 系统要求包括新用户登记功能、统计功能、查询功能、修改功能。题目建议使用如下结构体:Struct c;ient Char name20; Int sex; Int age; Char ID_card20; Int year; Int month; Int date;Sturct hotel Int Room_ID; Int tel; Int price; Bool sign; Struct client client_list;Roomnum三、 需求分析根据题目要求,应提供文件输入、输出、修改、删除、浏览等操作,可选择在程序中提供菜单选择功能以选择各个功能模
2、块。四、 总体设计系统 大于5小于1 在1-5之间1?2? 3? 4? 5?退出修改模块查询模块统计模块登记模块选1 选2 选3 选4 选5 登记模块:输入客人人数、客人姓名、性别、年龄、身份证号码、登记年月等信息。统计模块:统计房间使用情况。查询模块:查询已用、未用房间等信息。修改模块:提供客房信息、客人信息的修改。五、详细设计1、主函数主函数可采用菜单式选择方案,将各个功能以功能模块方式在菜单中呈现。结构流程如下:主菜单通过数字选择功能登记统计查询修改退出程序如下:void main() /*主菜单,选择数字来选择功能*/ int n,w=1; struct Hotel *info; wh
3、ile(w) puts("tt=主菜单=n"); puts("tt= 1 登记n"); puts("tt= 2 统计n"); puts("tt= 3 搜索n"); puts("tt= 4 修改n"); puts("tt= 5 退出n") printf("请选择(1-5):bb"); scanf("%d",&n); if(n<1|n>5) w=1; getchar(); switch(n) case 1:regi();
4、break; case 2:stat();break; case 3:search();break; case 4:modify();break; case 5:tuichu();break; default: break; getchar(); 2、登记模块 利用结构体数组输入客人姓名、性别、年龄等信息。结构流程图如下:登记模块判断输入数是否大于N输入客人信息程序如下:regi() int i,n; struct Hotel *info; char s10; char a10="have" printf(" 登记人数:n"); scanf("
5、%d",&n); for(i=0;i<n;i+) info=(struct Hotel*)malloc(sizeof(RoomNUM); if(info=0) printf(" 已记录n"); inputs(" t 房号:n",info->Room_ID,10); if(!(char*)(info->Room_ID)0) break; if(strcmp(a,info->person) inputs("t 姓名:n",info->Client_list.Name,20); inputs(
6、"t 性别:n",info->Client_list.Sex,10); inputs("t 年龄:n",info->Client_list.Age,10); inputs("t 身份证号:n",info->Client_list.ID_card,20); inputs("t 登记年份:n",info->Client_list.year,10); inputs("t 月份:n",info->Client_list.month,10); inputs("t 日
7、期:n",info->Client_list.date,10); inputs("t 电话:n",info->Tel,10); inputs("t 价格:n",info->Price,10); printf("t 已完成登记n"); start=dls_store(info,start); inputs(char *prompt, char *s,int count) char p255; do printf("%s",prompt); scanf("%s",p);
8、if(strlen(p)>count) printf(" too long!n "); while(strlen(p)>count); strcpy(s,p); 3、统计模块 用于统计已用、未用房间,以及输出已用和未用房间的房号。流程图如下:开始输出已用房信息输出未用房信息程序如下:stat() struct Hotel *info; char a10="null" char b10="have" int c,count=0; printf("t 统计已用房号 1, 统计未用房号 2 n"); scan
9、f("%d",&c); if(c=1) info=start; while(info) if(!strcmp(a,info->person) printf("房号 %s n",info->Room_ID); count+; info=info->next; printf("t已用房%sn",count); if(c=2) info=start; while(info) if(!strcmp(b,info->person) printf("t 房号 %s n",info->Roo
10、m_ID); count+; info=info->next; printf("t 未用房%sn",count); 4搜索模块 分不同条件查询。用菜单提供模块选择。结构流程图如下:搜索模块选择菜单按房间号查询按已用房查询按未用房查询退出程序如下:search() int b; printf(" t 按房号查询 1n"); printf(" t 查询已用房 2n"); printf(" t 查询未用房 3n"); printf(" t 回主菜单 4n"); do scanf("%d
11、",&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=info->next; printf("
12、 t 无法找到n"); return (NULL); search1() char Room_ID10; struct Hotel *info; printf(" t 输入房号 n"); scanf("%s",Room_ID); getchar(); info=find(Room_ID); if(!info) printf(" t 无法发现n"); else display(info); search2() struct Hotel *info; char a10="null" info=start; w
13、hile(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 "); info=info->next; 5修改模块 以菜单方式提供浏览、修改功能。流程图如下: 修改模
14、块判断选择功能判断是否存在输出“不存在”输出信息修改信息退出程序如下: modify() struct Hotel *info; char Room_ID10; char a10="have" char c10="null" int b,f; printf(" t 检索信息 1n"); printf(" t 修改信息 2n"); printf(" t 回主菜单 3n"); scanf("%d",&b); if(b=1)search(); if(b=2) printf(
15、" t 输入房间号n"); scanf("%s",Room_ID); info=find(Room_ID); if(!info)printf("t 找不到n"); else display(info);printf("t 进入修改.n"); if(!strcmp(a,info->person) inputs("t put null:n",info->person,10); if(!strcmp(c,info->person) inputs("t姓名:n",i
16、nfo->Client_list.Name,20); inputs("t性别:n",info->Client_list.Sex,10); inputs("t年龄:n",info->Client_list.Age,10); inputs("t身份证号:n",info->Client_list.ID_card,20); inputs("t登记年份:n",info->Client_list.year,10); inputs("t月份:n",info->Client_
17、list.month,10); inputs("t日期:n",info->Client_list.date,10); inputs("t电话:n",info->Tel,10); inputs("t价格:n",info->Price,10); if(b=3) return; 五、 运行结果1 主菜单2 登记模块3 搜索模块4 修改模块六、 源程序#include"stdio.h"#include"stdlib.h"#include "string.h"#def
18、ine NUM 100regi();modify();save();search();stat();tuichu();search1();search2();search3();inputs(char *prompt, char *s,int count);struct Hotel *dls_store(struct Hotel *i,struct Hotel *top); struct Hotel *find(char *Room_ID); display(struct Hotel *info);struct Client char Name20; char Sex10; char Age1
19、0; char ID_card20; char year10; char month10; char date10;struct Hotel char Room_ID10; char Tel10; char Price10; char person10; struct Client Client_list; struct Hotel *next; struct Hotel *prior;RoomNUM;struct Hotel *start=NULL;struct Hotel *last=NULL;void main() int n,w=1; struct Hotel *info; while
20、(w) puts("tt=n"); puts("tt=主菜单=n"); puts("tt= 1 登记 =n"); puts("tt= 2 统计 =n"); puts("tt= 3 搜索 =n"); puts("tt= 4 修改 =n"); puts("tt= 5 退出 =n"); puts("tt=n"); puts("tt=n"); printf("请选择(1-5):bb"); scanf(&q
21、uot;%d",&n); if(n<1|n>5) w=1; getchar(); switch(n) case 1:regi();break; case 2:stat();break; case 3:search();break; case 4:modify();break; case 5:tuichu();break; default: break; getchar(); regi() int i,n; struct Hotel *info; char s10; char a10="have" printf(" 登记人数:n&quo
22、t;); scanf("%d",&n); for(i=0;i<n;i+) info=(struct Hotel*)malloc(sizeof(RoomNUM); if(info=0) printf(" 已记录n"); inputs(" t 房号:n",info->Room_ID,10); if(!(char*)(info->Room_ID)0) break; if(strcmp(a,info->person) inputs("t 姓名:n",info->Client_list.
23、Name,20); inputs("t 性别:n",info->Client_list.Sex,10); inputs("t 年龄:n",info->Client_list.Age,10); inputs("t 身份证号:n",info->Client_list.ID_card,20); inputs("t 登记年份:n",info->Client_list.year,10); inputs("t 月份:n",info->Client_list.month,10);
24、 inputs("t 日期:n",info->Client_list.date,10); inputs("t 电话:n",info->Tel,10); inputs("t 价格:n",info->Price,10); printf("t 已完成登记n"); start=dls_store(info,start); inputs(char *prompt, char *s,int count) char p255; do printf("%s",prompt); scanf(&q
25、uot;%s",p); if(strlen(p)>count) printf(" 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; ol
26、d=NULL; while(p) if(strcmp(p->Room_ID,i->Room_ID)<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; stat() s
27、truct Hotel *info; char a10="null" char b10="have" int c,count=0; printf("t 统计已用房号 1, 统计未用房号 2 n"); scanf("%d",&c); if(c=1) info=start; while(info) if(!strcmp(a,info->person) printf("房号 %s n",info->Room_ID); count+; info=info->next; prin
28、tf("t已用房%sn",count); if(c=2) info=start; while(info) if(!strcmp(b,info->person) printf("t 房号 %s n",info->Room_ID); count+; info=info->next; printf("t 未用房%sn",count); display(struct Hotel *info) printf("tt 姓名:%sn",info->Client_list.Name); printf(&qu
29、ot;tt 性别:%sn",info->Client_list.Sex); printf("tt 年龄:%sn",info->Client_list.Age); printf("tt 身份证号:%sn",info->Client_list.ID_card); printf("tt 登记年份:%sn",info->Client_list.year); printf("tt 月份:%sn",info->Client_list.month); printf("tt 日期:
30、%sn",info->Client_list.date); printf("tt 电话:%sn",info->Tel); printf("tt 价格:%sn",info->Price); printf("n"); search() int b; printf(" t 按房号查询 1n"); printf(" t 查询已用房 2n"); printf(" t 查询未用房 3n"); printf(" t 回主菜单 4n"); do
31、 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=info->next
32、; printf(" t 无法找到n"); return (NULL); search1() char Room_ID10; struct Hotel *info; printf(" t 输入房号 n"); scanf("%s",Room_ID); getchar(); info=find(Room_ID); if(!info) printf(" t 无法发现n"); else display(info); search2() struct Hotel *info; char a10="null"
33、; 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 "); info=info->next; save() register
34、int t,size; struct Hotel *info; char *p; FILE *fp; if(fp=fopen("mlist","wb")=0) printf(" t 无法打开文件n"); exit(0); printf("t 保存中n"); size=sizeof(RoomNUM); info=start; while(info) p=(char*)info; for(t=0;t<size;+t) putc(*p+,fp); info=info->next; putc(EOF,fp); fclose(fp); printf("t 已保存n"); modify() struct Hotel *info; char Room_ID10; char a10="have" char c10="
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 景德镇陶瓷大学《微积分一》2023-2024学年第二学期期末试卷
- 湖南第一师范学院《数学专题讲座》2023-2024学年第一学期期末试卷
- 湖北艺术职业学院《影视文学与评论》2023-2024学年第一学期期末试卷
- 郑州轻工业大学《乐理基础与视唱(一)》2023-2024学年第二学期期末试卷
- 湛江幼儿师范专科学校《单片机原理及应用》2023-2024学年第二学期期末试卷
- 委托房屋买卖合同书
- 房屋租赁合同附清单
- 买卖暂不过户二手房合同
- 垃圾清运清理合同
- 技术检测服务合同
- 2025陕西核工业工程勘察院有限公司招聘(21人)笔试参考题库附带答案详解
- 2025年山东、湖北部分重点中学高中毕业班第二次模拟考试数学试题含解析
- 湖北省孝感市高新区2023-2024学年七年级下学期数学期中考试试卷(含答案)
- 8.2 诚信经营 依法纳税课件-高中政治统编版选择性必修二法律与生活
- 领导带班及24小时值班制度
- 2025年超高功率大吨位电弧炉项目发展计划
- DB32T 5076-2025 奶牛规模化养殖设施设备配置技术规范
- 肿瘤患者的血栓预防及护理
- 作风建设方面个人简短总结
- JJF 1214-2008长度基线场校准规范
- 《个人信息保护法》全文学习PPT课件(带内容)
评论
0/150
提交评论