程序代码N:最终改进版代码(利用结构体储存多种类型的数据)好处:比数组能储存更多类型的数据!#includeiostream#includestring#includecstdlib//常用函数库usingnamespacestd;/*在c++中struct和类的区别在于struct不能有方法,所有成员是public的*/structRoom{intNumber;intPrice;intState;intdays;stringName;stringPhone;stringID;};//room;可以在声明struct的时候声明一个struct实例Roomroom[80];classBookRoom//定义预定房间类{private:stringcName;//顾客姓名intstayTime;//预定天数introomType;//房间类型(1.标准单人间2.大床房3.标准双人间4.套房)stringphoneNum;//预留手机号public:voidsetData(){stringname;inttime;inttype;stringnum;cout您好,请输入您的姓名:endl;cinname;cName=name;cout预定天数为:endl;cintime;stayTime=time;cout想要预定的房间类型:1.标准单人间100/天2.大床房200/天3.标准双人间300/天4.套房400/天endl;cintype;roomType=type;cout预留手机号:endl;cinnum;phoneNum=num;};voidBook(){cout正在预定...endl;switch(this-roomType){case1:for(inti=0;i20;i++){if(room[i].State==0)//房间无人占用且无人预定{room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;cout预定成功!房间号:room[i].Numberendlendl;room[i].State=1;break;//已被预订}elsecoutroom[i].Number号房间已有人endl;}break;case2:for(inti=20;i40;i++){if(room[i].State==0){room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;cout预定成功!房间号:room[i].Numberendlendl;room[i].State=1;break;}elsecoutroom[i].Number号房间已有人endl;}break;case3:for(inti=40;i60;i++){if(room[i].State==0){room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;cout预定成功!房间号:room[i].Numberendlendl;room[i].State=1;break;}elsecoutroom[i].Number号房间已有人endl;}break;case4:for(inti=60;i80;i++){if(room[i].State==0){room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;cout预定成功!房间号:room[i].Numberendlendl;room[i].State=1;break;}elsecoutroom[i].Number号房间已有人endl;}break;default:cout您输入的房间类型有误!endl;}};};classCheckIn//定义办理入住类{private:stringcName;stringcSex;stringidNum;//身份证号intcheck_inDate;//入住日期intstayTime;introomType;stringphoneNum;public:voidunbooked(){stringname;stringsex;stringidnum;intdate;inttime;inttype;stringnum;cout客户姓名:endl;cinname;cName=name;cout客户性别:endl;cinsex;cSex=sex;cout客户身份证号:endl;cinidnum;idNum=idnum;cout入住日期:endl;cindate;check_inDate=date;cout占用天数:endl;cintime;stayTime=time;cout房间类型:1.标准单人间100/天2.大床房200/天3.标准双人间300/天4.套房400/天endl;cintype;roomType=type;cout客户手机号:endl;cinnum;phoneNum=num;switch(this-roomType){case1:for(inti=0;i20;i++){if(room[i].State==0){room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;room[i].ID=this-idNum;cout入住成功!房间号:room[i].Numberendlendl;cout请支付200元押金endlendl;room[i].State=1;break;}elsecout抱歉,该房间类型没有了endl;}break;case2:for(inti=20;i40;i++){if(room[i].State==0){room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;room[i].ID=this-idNum;cout入住成功!房间号:room[i].Numberendlendl;cout请支付400元押金endlendl;room[i].State=1;break;}elsecout抱歉,该房间类型没有了endl;}break;case3:for(inti=40;i60;i++){if(room[i].State==0){room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;room[i].ID=this-idNum;cout入住成功!房间号:room[i].Numberendlendl;cout请支付600元押金endlendl;room[i].State=1;break;}elsecout抱歉,该房间类型没有了endl;}break;case4:for(inti=60;i80;i++){if(room[i].State==0){room[i].days=this-stayTime;room[i].Name=this-cName;room[i].Phone=this-phoneNum;room[i].Price*=this-stayTime;room[i].ID=this-idNum;cout入住成功!房间号:room[i].Numberendlendl;cout请支付800元押金endlendl;room[i].State=1;break;}elsecout抱歉,该房间类型没有了endl;}break;default:cout您输入的房间类型有误!endl;}}voidbooked(){stringcompareItem;stringid_num;cout请输入您的姓名或者手机号:endl;cincompareItem;for(inti=0;i80;i++){if(room[i].Name==compareItem||room[i].Phone==compareItem){cout验证成功!请支付:(room[i].Price*2)元押金endl;cout请登记客户的身份证号:endl;cinid_num;idNum=id_num;room[i].ID=idNum;cout房间号为:room[i].Numberendl欢迎入住!endlendl;break;}}}};classcheckOut{private:stringname;intnumber;intdays;intprice;public:voidcheckout(){intexpense;cout请输入房间号:endl;cinnumber;cout请输入姓名:endl;cinname;cout请输入实际住宿天数:endl;cindays;for(inti=0;i80;i++){if((room[i].Name==name)&&(room[i].Number==number)){expense=days*(room[i].Number/100*100);cout房间号为room[i].Number的房间实际消费为expense元endl;cout押金为:room[i].Priceendl;if(expenseroom[i].Price)cout请补交(expense-room[i].Price)元endl;elsecout退回:(room[i].Price-expense)元endl;break;}elsecoutroom[i].Number号房不符合endl;}cout房费核算清后请安任意键继续endlendl;system(pause);cout感谢入住本酒店,欢迎下次光临!endlendl;}};voidmenu(){cout欢迎使用酒店管理系统!endl;cout请选择:endl;cout1.预定房间endl;cout2.办理入住endl;cout3.退房结账endl;cout4.退出系统endl;}voidinit(){intn=101;for(inti=0;i20;i++){room[i].Number=n++;room[i].Price=100;room[i].State=0;}n=201;for(inti=20;i40;i++){