资源描述:
《酒店管理系统代码(C语言版).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、.#include#include#include//房间信息结构体structNode{intCount;//指示该房间有多少个房客charnameOne[20];//房客1的名字charnameTwo[20];//房客2的名字intsexOne;//房客1的性别-1代表女,0代表没有,1代表男intsexTwo;//房客2的性别introomNumber;//房间号}roomArray[5];//初始化房间数组voidInitArray(){inti;word专业资料.f
2、or(i=0;i<5;i++){roomArray[i].roomNumber=301+i;memset(roomArray[i].nameOne,0,20);memset(roomArray[i].nameTwo,0,20);roomArray[i].sexOne=0;roomArray[i].sexTwo=0;roomArray[i].Count=0;}}voidfun1()//旅客入住的操作{charname[20];intsex;inti;printf("输入入住旅客姓名和性别(空格隔开,1为男,-1为女):");sca
3、nf("%s%d",name,&sex);for(i=0;i<5;i++){word专业资料.if(roomArray[i].Count==2){continue;}elseif(roomArray[i].Count==1){if(roomArray[i].sexOne!=sex){continue;}strcpy(roomArray[i].nameTwo,name);roomArray[i].sexTwo=sex;roomArray[i].Count++;system("cls");printf("客人已经成功入住,在房间%d",
4、roomArray[i].roomNumber);return;;}else{strcpy(roomArray[i].nameOne,name);roomArray[i].sexOne=sex;word专业资料.roomArray[i].Count++;system("cls");printf("客人已经成功入住,在房间%d",roomArray[i].roomNumber);return;;}}printf("无法入住,房间已经住满或者是没有适合的房间");}voidfun2()//退房操作{inti;charname[20];p
5、rintf("请输入要退房旅客的姓名:");scanf("%s",name);for(i=0;i<5;i++){if(strcmp(roomArray[i].nameOne,name)==0){memset(roomArray[i].nameOne,0,20);word专业资料.roomArray[i].sexOne=0;roomArray[i].Count--;system("cls");printf("%s客人已经成功退房",name);return;}if(strcmp(roomArray[i].nameTwo,name)
6、==0){memset(roomArray[i].nameTwo,0,20);roomArray[i].sexTwo=0;roomArray[i].Count--;system("cls");printf("%s客人已经成功退房",name);return;}}system("cls");printf("没有名为%s的客人,请检查输入的正确性!",name);}word专业资料.voidfun3()//查询操作{intindex;inti;charname[20];intnumber;intj;system("cls");p
7、rintf("***************请选择要查询的种类***************");printf("1.所有房间入住信息显示");printf("2.按照姓名查询");printf("3.按照房号查询");scanf("%d",&index);if(index==1){for(i=0;i<5;i++){printf("房间%d:",roomArray[i].roomNumber);if(roomArray[i].Count==0)word专业资料.{printf("没有客人入住");}elseif(
8、roomArray[i].Count==1){if(roomArray[i].sexTwo==0){printf("当前有1位客人->姓名%s,",roomArray[i].nameOne);if(roomArray[i].sexOn