收藏 分享(赏)

酒店管理系统C语言版.doc

上传人:精品资料 文档编号:8574643 上传时间:2019-07-03 格式:DOC 页数:6 大小:31KB
下载 相关 举报
酒店管理系统C语言版.doc_第1页
第1页 / 共6页
酒店管理系统C语言版.doc_第2页
第2页 / 共6页
酒店管理系统C语言版.doc_第3页
第3页 / 共6页
酒店管理系统C语言版.doc_第4页
第4页 / 共6页
酒店管理系统C语言版.doc_第5页
第5页 / 共6页
点击查看更多>>
资源描述

1、#include#includestruct peopledatachar name11;char sex3;int age;int idcard2;struct dateint year;int month;int day;int time;/住宿时间。;typedef structint number;char kind;struct peopledata people;struct date time;rooms;void adddata()FILE *fp;rooms room;char tag,select;int i;doprintf(“房间编号:“);scanf(“%d“,ffl

2、ush(stdin);printf(“房间类型:“);scanf(“%c“,printf(“住宿人员信息:n“);printf(“tt 姓名:“);fflush(stdin);scanf(“%s“,room.people.name);fflush(stdin);printf(“tt 性别:“);gets(room.people.sex);printf(“tt 年龄:“);scanf(“%d“,printf(“tt 请输入身份证号码: “);for(i=0;i2;i+)scanf(“%d“,printf(“入住时间:n“);printf(“tt 年:“);scanf(“%d“,printf(“t

3、t 月:“);scanf(“%d“,printf(“tt 日:“);scanf(“%d“,printf(“入住时长:“);scanf(“%d“,fflush(stdin);if(fp=fopen(“d:酒店住宿登记表.txt“,“a“)=NULL)printf(“打开文件”酒店住宿登记表“失败,按任意键退出。n“);exit(0);elseprintf(“确定要写入资料吗?(y/n)n“);scanf(“%c“,fflush(stdin);if(select=y)fwrite(if(ferror(fp)!=0)printf(“写入资料失败,按任意键退出。n“);exit(0);printf(“

4、要继续添加?(y/n)n“);scanf(“%c“,fflush(stdin);elseprintf(“要继续添加吗?(y/n)n“);scanf(“%c“,fflush(stdin);fclose(fp); while(tag=y);void updata()FILE *fp;rooms room;int number,i;printf(“请输入要更新的信息的房间编号:n“);scanf(“%d“,if(fp=fopen(“d:酒店住宿登记表.txt“,“r+“)=NULL)printf(“打开文件”酒店住宿登记表“失败,按任意键退出。n“);exit(0);elserewind(fp);f

5、read(while(!feof(fp)if(room.number=number)break;fread(if(!feof(fp)printf(“查询成功!n“);printf(“*n“);printf(“tn“);printf(“tt 房间号 t 房间类型t“);printf(“tt%dt%cn“,room.number,room.kind);printf(“住宿人员信息:n“);printf(“tt 姓名 t 性别t 年龄“);printf(“tt%st%st%dn“,room.people.name,room.people.sex,room.people.age);printf(“身份

6、证号:“);for(i=0;i2;i+)printf(“%d“,room.people.idcardi);putchar(n);printf(“入住时间:n“);printf(“%d 年%d 月%d 日n“,room.time.year,room.time.month,room.time.day);printf(“入住时长:n“);printf(“%d 天n“,room.time.time);printf(“tn“);printf(“*n“);printf(“请输入更新信息:n“);printf(“房间编号:“);scanf(“%d“,fflush(stdin);printf(“房间类型:“)

7、;scanf(“%c“,printf(“住宿人员信息:n“);printf(“tt 姓名: “);fflush(stdin);scanf(“%s“,room.people.name);fflush(stdin);printf(“tt 性别: “);gets(room.people.sex);printf(“tt 年龄: “);scanf(“%d“,printf(“tt 请输入身份证号码: “);for(i=0;i2;i+)scanf(“%d“,printf(“入住时间:n“);printf(“tt 年: “);scanf(“%d“,printf(“tt 月: “);scanf(“%d“,pri

8、ntf(“tt 日: “);scanf(“%d“,printf(“入住时长:“);scanf(“%d“,fflush(stdin);fclose(fp);void searchdata()FILE *fp;rooms room;int number,i;printf(“请输入要查询的信息的房间编号:n“);scanf(“%d“,if(fp=fopen(“d:酒店住宿登记表.txt“,“r+“)=NULL)printf(“打开文件”酒店住宿登记表“失败,按任意键退出。n“);exit(0);elserewind(fp);fread(while(!feof(fp)if(room.number=nu

9、mber)break;fread(if(!feof(fp)printf(“查询成功!n“);printf(“*n“);printf(“tn“);printf(“tt 房间号 t 房间类型t“);printf(“tt%dt%cn“,room.number,room.kind);printf(“住宿人员信息:n“);printf(“tt 姓名 t 性别t 年龄“);printf(“tt%st%st%dn“,room.people.name,room.people.sex,room.people.age);printf(“身份证号:“);for(i=0;i2;i+)printf(“%d“,room.

10、people.idcardi);putchar(n);printf(“入住时间:n“);printf(“%d 年%d 月%d 日n“,room.time.year,room.time.month,room.time.day);printf(“入住时长:n“);printf(“%d 天n“,room.time.time);printf(“tn“);printf(“*n“);elseprintf(“无此房间号n“);clearerr (fp);fclose(fp);int main()int select;printf(“欢迎使用酒店管理系统n“);doprintf(“请选择:n“);printf(“1.增加信息 2.修改信息 3.查询信息 4.退出n“);scanf(“%d“,switch(select)case 1:adddata();break;case 2:updata();break;case 3:searchdata();break;case 4:break;while(select!=4);system(“PAUSE“);return 0;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报