资源预览内容
第1页 / 共18页
第2页 / 共18页
第3页 / 共18页
第4页 / 共18页
第5页 / 共18页
第6页 / 共18页
第7页 / 共18页
第8页 / 共18页
第9页 / 共18页
第10页 / 共18页
亲,该文档总共18页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
extern int GuestNumber;#include Structs.hint GuestNumber;int GuestNumber=0;void main(void) LoadHotelInfo(rooms); LoadGuestInfo(); LoadGARInfo(); handlemenu();void printMenu() printf( 1 查看旅店信息n 2 查看某一房间信息n 3 查看旅客信息n 4 查看某一旅客信息n 5 旅客入住n 6 旅客换房n 7 旅客退房n 8 退出n );void handlemenu() int i=0; do printMenu(); printf(请选择:); scanf(%d,&i); fflush(stdin); switch(i) case 1: ViewAllHotel(); printf(nn); break; case 2: ViewOneRoom(); printf(nn); break; case 3: ViewAllGuest(); printf(nn); break; case 4: ViewOneGuest(); printf(nn); break; case 5: GuestCheckIn(); printf(nn); break; case 6: GuestChangeRoom(); printf(nn); break; case 7: GuestCheckOut(); printf(nn); break; case 8: SabeGARInfo(); SabeGuestInfo(); SaveHotelInfo(rooms); exit(0); while(1);#include#include#include#include#include#define FLOORNUMBER 4#define ROOMNUMBER 5typedef enum RoomTypeSingle=1,Double=2,Triangle=3RoomType;typedef struct room int RoomNumber; RoomType roomtype; int CheckInNumber; int RoomPrice;Room;typedef struct guestandroom char GuestID20; int GustInRoom; char CheckInTime30; char CheckOutTime30;GuestAndRoom;typedef struct guestandroom charName10; char sex3; char ID20;Guest;void menu();void LoadHotelInfo(Room pararoomFLOORNUMBER);void ViewAllHotel();void SaveHotelInfo(Room pararoomFLOORNUMBER);void LoadGuestInfo();void SaveGuestInfo();void viewOneGuest();void ViewAllGuest();void AppendGuestInfo();void GuestCheckIn();void GuestChangeRoom();void GuestCheckOut();void ChangeBookDay();void AppendGARInfo();void LoadGARInfo();void SabeGARInfo();void AppendGuestHistoryInfo(int Guesti,int GARj);void handlemenu();void peintMenu();void ViewOneRoom();int IsOldGuest();int DelGuest(char ID);int CountGuest(Room pararoomFLOORNUMBER);int CheckRAGIndex(char ID);int CheckGreeRoom(char Sex);int FindOneGuest();char *CheckRoomSex(int RoomNumber);Room roomsFLORNUMBERROOMNUMBER;Guest ptoguest55;GuestAndRoom GAR55;#include Structs.hextern int GuestNumber;void AppendGARInfo() FILE *fp; if(fp=fopen(guestandroom.txt,a)=NULL) printf(文件读取失败); exit(0); fprintf(fp,%dt%st%sn,GARGuestNumber-1.GuestInRoom,GARGuestNumber-1.CheckInTime); fclose(fp);void LoadGARInfo() FILE *fp; int iCount=0; char temp10=; if(fp=fopen(guestandroom.txt,r)=NULL) printf(文件读取失败!决策管理n); exit(0); fscanf(fpp,%*s %*s %*s%*s,temp,temp,temp,temp); for(iCount=0;iCountGuestNumber;iCount+) fscanf(fp,%d%sttt,&GARiCount.GuestInRoom,GARiCount.GuestID); fgets(GARiCount.CheckInTime,25,fp); strcpy(GARiCount.CheckOutTime,); fclose(fp);void SaveGARInfo() FILE *fp; int iCount=0; if(fp=fopen(guestandroom.txt,w)=NULL) printf(文件读取失败); exit(0); fprintf(fp,%st%st%st%sn,房间,身份证,入住时间,退房时间); for(iCount=0;iCountGuestNumber;iCount+) fprintf(fp,%dtt%sttt%sttt%sn,GARiCount.GuestInRoom,GARiCount.GuestID,GARiCount.CheckInTime,GARiCount.CheckOutTime); fclose(fp);int CheckRAGIndex(char ID) int gindex=-1; int garindex=-1; int icount; for(icount=0;icountGuestNumber;icount+) if(!strcmp(ID,ptoguesticount.ID) gindex=icount; break; if(gindex!=-1) for(icount=0;icountGuestNumber;icount+) if(!strcmp(ptoguestgindex.ID,GARicount.GuestID) garindex=gindex; break; return garindex;void GuestCheckIn() int NewRoomNumber; int NewGuestSexN; int i; int j; int CheckSex=0; time-t t; t=time(NULL); printf(请输入旅客姓名:n); scanf(%s,ptoguestGuestNumber.Name); do printf(请选择旅客性别:n); printf(1 男n2 女n); scanf(%d,&NewGuestSexN); switch(NewGuestSexN); case 1: strcpy(ptoguestGuestNumber.sex,男); break; case 2: strcpy(ptoguestGuestNumber.sex,女); break; while(NewGuestSexN!=1&NewGuestSexN!=2); printf(请输入旅客身份证号码:n); scanf(%s,ptoguestGuestNumber.ID); CheckSex=CheckGreeToom(ptoguestGuestNumber.sex); if(!CheckSex) strcpy(ptoguestGuestNumber.ID,); strcpy(ptoguestGuestNumber.Name, ); strcpy(ptoguestGuestNumber.sex,); return; printf(请输入旅客选择入住房间号码:n); scanf(%d,&NewRoomNumber); for(i=0;i4;i+) for(j=0;j5;j+) if(roomsij.RoomNumber=NewRoomNumber) roomsij.CheckInNumber=roomsij.CheckInNumber+1; GuestNumber+=1; strcpy(GARGuestNumber-1.CheckInTim
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号