两个情况,一是我没用链表,二是入住登记时,选择继续登记是无法退出的
1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<conio.h> 5 6 int roomnum[5]={301,302,303,304,305}; 7 8 int menu(); 9 struct stu 10 { 11 char name[10]; 12 char sex[3]; 13 int empty=0; 14 } Rooms[5]; 15 16 void search() 17 { 18 printf("可以入住的房间有:"); 19 for(int i=0;i<5;i++) 20 { 21 if(Rooms[i].empty==0) 22 { 23 printf("%d ",301+i); 24 } 25 } 26 printf(" "); 27 } 28 29 int check(int room) 30 { 31 32 if(room>305||room<301) 33 return 0; 34 if(Rooms[room-301].empty==0) 35 return 1; 36 else 37 return 0; 38 } 39 40 void Getout() 41 { 42 system("cls"); 43 int getoutnum; 44 char a; 45 printf("请输入退房顾客的房间号: "); 46 scanf("%d",&getoutnum); 47 printf("确认输入Y,返回主菜单输入N "); 48 a=getch(); 49 if(a=='Y'||a=='y') 50 { 51 strcpy(Rooms[getoutnum-301].name,"