【2017年整理】C语言旅馆信息管理系统

上传人:豆浆 文档编号:1789130 上传时间:2017-07-14 格式:DOC 页数:12 大小:50KB
返回 下载 相关 举报
【2017年整理】C语言旅馆信息管理系统_第1页
第1页 / 共12页
【2017年整理】C语言旅馆信息管理系统_第2页
第2页 / 共12页
【2017年整理】C语言旅馆信息管理系统_第3页
第3页 / 共12页
【2017年整理】C语言旅馆信息管理系统_第4页
第4页 / 共12页
【2017年整理】C语言旅馆信息管理系统_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《【2017年整理】C语言旅馆信息管理系统》由会员分享,可在线阅读,更多相关《【2017年整理】C语言旅馆信息管理系统(12页珍藏版)》请在金锄头文库上搜索。

1、/*题目:旅店信息管理系统*小组成员:闫若琳 戴雨晨 马渊沐 张子飞 李闯王浩 崔以博 孙浩浩 李春普 温健成*/#include #include #include #include #define MIN 1#define MAX 30#define LEN sizeof(struct Hotel) /用 LEN 代替结构体的长度void regeist();void out_information();void search_number();void show_all();void search_name();void change();void fire();struct Hotel

2、 *load();FILE *fp;struct Hotel int room_number;char name 20;char sex10;char ID 20;float paid10;int inyear ;int inmonth ;int inday ;struct Hotel *next ;struct Hotel *load() /定义 load 函数读取当前的信息,并存到内存链表中struct Hotel *head,*pb, *s ;pb=(struct Hotel *)malloc(LEN); /开辟新的节点s =(struct Hotel *)malloc(LEN);if(

3、pb=NULL)|(s=NULL)printf (动态内存分配失败!n);getch();exit(0);if(fp=fopen(resturant.txt,rb)=NULL)printf (无法打开文件!n);getch();exit(0);head = pb;while (fread (s,LEN,1,fp) /读取当前的信息,并存到链表中pb-next = s;pb = s;s = (struct Hotel *)malloc(LEN);pb-next =NULL;return head ; /返回链表的头指针int main () /崔以博、孙浩浩 char choice ;do pr

4、intf (nn-欢迎使用旅店信息管理系统-nn);printf (1.查看旅店信息n2. 查看某一房间信息n3.查看旅客信息n);printf (4.查找某一旅客信息n5. 旅客入住n6.旅客换房n7.旅客退房n8.退出n);printf (n-n);choice=getch();switch (choice) case 1:out_information();break; case 2:search_number();break;case 3:show_all();break;case 4:search_name();break;case 5:regeist();break;case 6:

5、change();break;case 7:fire();break;case 8:exit(0);break;default :printf (Error !);break ;printf (nn 请按任意键继续 !n);getch();system(cls);while(1);return 0 ;void out_information() /张子飞:定义 out_information 函数,完成查看旅店信息功能FILE *fp;char ch ;if (fp=fopen(information.txt,r)=NULL) printf (无法打开文件!n);getch();exit(0)

6、;ch=fgetc(fp);system(cls);printf(nnttt 旅店信息介绍: (若没有信息请返回创建);printf (n-nnt);while (ch!=EOF)putchar(ch);ch=fgetc(fp);fclose(fp);void search_number () /李春普、温健成:定义 search_number 函数,用来完成查看某一房间的信息char ch2 ;int room_number ;struct Hotel *head, *pa ;head=load();printf (n 请输入需要查看的房间序号:(%d%d):,MIN,MAX);scanf

7、(%d,&room_number);pa= head-next;if (room_numberMAX)printf (anError!);return ;doif (pa)if(room_number=pa-room_number) /如果找到相应信息,则输出printf (n);printf (roomnumber:t%d,pa-room_number);printf (n);printf (name:tt%s,pa-name);printf (n);printf (sex:tt%s,pa-sex);printf (n);printf (ID:tt%s,pa-ID);printf (n);p

8、rintf (paid:tt%s,pa-paid);printf (n);printf (%d %d %d,pa-inyear,pa-inmonth,pa-inday);printf (n);printf (n 请选择是否继续查看信息(y/n):n);scanf (%s,ch);if(strcmp(ch,Y)!=0)&(strcmp(ch,y)!=0)return;elseprintf (n 请输入需要查看的房间序号:(%d%d):,MIN,MAX);scanf (%d,&room_number);pa= head-next;if (room_numberMAX)printf ( 无此房间!)

9、;return;continue ;pa = pa-next;elseprintf (n 该房间还没有旅客入住);return;while(1);void show_all() /戴雨晨:定义是 show_all 函数,用来显示所有旅客信息struct Hotel *head, *pa ;head=load();pa= head-next;printf (n 所有入住旅客的信息如下:n);while (pa) /显示所有的旅客信息printf (n);printf (roomnumber:t%d,pa-room_number);printf (n);printf (name:tt%s,pa-n

10、ame);printf (n);printf (sex:tt%s,pa-sex);printf (n);printf (ID:tt%s,pa-ID);printf (n);printf (paid:tt%s,pa-paid);printf (n);printf (date:tt%d %d %d,pa-inyear,pa-inmonth,pa-inday);printf (n);pa = pa-next;void search_name () /马渊沐:定义 search_name 函数,用来完成查看某一旅客的信息char ch2 ;char inname20 ; /用数组 inname20来储

11、存需要查询的旅客 namestruct Hotel *head, *pa ;head=load();printf (n 请输入需要查看的旅客姓名:);scanf (%s,inname);pa= head-next;doif (pa)if(strcmp(inname,pa-name)=0)printf (n);printf (roomnumber:t%d,pa-room_number);printf (n);printf (name:tt%s,pa-name);printf (n);printf (sex:tt%s,pa-sex);printf (n);printf (ID:tt%s,pa-ID

12、);printf (n);printf (paid:tt%s,pa-paid);printf (n);printf (date:tt%d %d %d,pa-inyear,pa-inmonth,pa-inday);printf (n);printf (n 请选择是否继续查看信息(y/n):n);scanf (%s,ch);if(strcmp(ch,Y)!=0)&(strcmp(ch,y)!=0)return;elseprintf (n 请输入需要查看的旅客姓名:);scanf (%s,inname);pa= head-next;continue ;pa = pa-next;else printf

13、 (n 没有查到该旅客的信息);return ;while(1);void regeist() /闫若琳:定义 regeist 函数实现入住功能char ch2 ;int number ;struct Hotel *head,*p1,*p2,*pa;head=load();pa= head-next;printf (n 已入住房间:n);while (pa)printf (n);printf (roomnumber:t%d,pa-room_number);pa = pa-next;fclose(fp);if(fp=fopen(resturant.txt,a+)=NULL)printf (无法打

14、开文件!n);getch();exit(0);head=NULL;p1=(struct Hotel *)malloc(LEN);p2=(struct Hotel *)malloc(LEN);if (p1=NULL)|(p2=NULL)printf (动态内存分配失败!n);getch();exit(0);printf (n 请登记入住信息!n);printf (请选择房间号(%d%d) :,MIN,MAX);scanf (%d,&number);if (numberMAX)printf (无此房间!);return;p1-room_number=number ; /在该房间没有旅客时,登记入住printf (name:t);scanf (%s,&p1-name);p

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 经济/贸易/财会 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号