酒店管理系统
#include <stdio.h>#include <string.h>#include<windows.h>#define N 5struct room{ char name[2][20]; char sex[2]; int intx[2],roomnum;};
struct room broom[N] = { {{" "," "},{' ',' '},{0,0},301},{{" "," "},{' ',' '},{0,0},302}, {{" "," "},{' ',' '},{0,0},303},{{" "," "},{' ',' '},{0,0},304}, {{" "," "},{' ',' '},{0,0},305} };void checkin();void checkout();void lookfor();void main(void){ int intj=0; while (intj != 4)//主菜单 { printf("\t\tPlease Select:\n\t\t1.Check In\n\t\t2.Check Out\n\t\t3.Search\n\t\t4.Exit\n\t\tPlease Select a Task:"); scanf("%d",&intj); if ( intj == 1 ) { checkin(); } else if ( intj == 2) { checkout(); } else if ( intj == 3) { lookfor(); } else if ( intj == 4 ) { char ch; printf("\t\tAre You Sure?(Y/N):"); getchar(); ch = getchar(); if ( ch != 'Y' && ch != 'y') { intj = 0; } } else { printf ("\t\tWarning : Wrong Task! Please Select Again\n"); } }}
void checkin()//录入模块 { char name[20],sex,ch; int inti=0,intj=0; printf ("\t\tInput Information(Name sex(F/M)):"); scanf ("%s %c",name,&sex); printf ("\t\tAvailable:\n"); for (inti=0;inti<N;inti++)//查找可用床位 { if (broom[inti].intx[0] != 1 && broom[inti].intx[1] != 1) { printf ("\t\t%d %d\n\t\t%d %d\n",301+inti,1,301+inti,2); intj++; } else if (broom[inti].intx[0] == 1 && broom[inti].sex[0] == sex) { printf("\t\t%d %d\n",301+inti,2); intj++; } else if (broom[inti].intx[1] == 1 && broom[inti].sex[1] == sex) { printf ("\t\t%d %d\n",301+inti,1); intj++; } else { ; } } if ( intj == 0 )//录入信息,完成入住 { printf("\t\tNo Bed Left"); system("cls"); } else { int roomnum,bednum;lp1: printf ("\t\tPlease Select Room And bed:"); getchar(); scanf("%d%d",&roomnum,&bednum); if (roomnum > 305 || roomnum < 301 || bednum > 2 || bednum < 1) { printf ("\t\tWrong Room Number Or Bed Number!\n"); goto lp1; } strcpy (broom[roomnum-301].name,name); broom[roomnum-301].intx = 1; broom[roomnum-301].sex = sex; printf ("\t\tSucceed\n\t\tContinue Checking In?(Y/N):"); getchar(); ch = getchar(); if ( ch == 'Y' || ch == 'y' ) { system("cls"); checkin(); } system("cls"); }}void checkout()//注销 { char name[20],ch; int inti=0,intj=0,intx=0; printf ("\t\tPlease Input Name:"); getchar(); gets(name); for (inti=0;inti<N;inti++) { for (intj=0;intj<2;intj++) { if ( strcmp(broom[inti].name[intj],name) == 0 ) { intx = 1; break; } } if ( intx == 1 ) { break; } } printf ("\t\tAre You Sure?(Y/N)"); ch=getchar(); if ( ch == 'Y' || ch == 'y' ) { broom[inti].intx[intj] = 0; printf ("\t\tSucceed"); } system("pause"); system("cls"); }void lookfor()//查找住客 { int inti = 0,intj = 0;lp2: printf ("\t\t1.By Name\n\t\t2.By Roomnumber\n\t\tPlease select:");//选择查找方式 scanf ("%d",&inti); if ( inti > 2 || inti < 1) { printf ("\t\tWrong Number!\n"); goto lp2; } if ( inti == 1 )//根据姓名查找 { char name[20]; printf("\t\tPlease Input Name:"); getchar(); gets(name); for (inti=0;inti<N;inti++) { for (intj=0;intj<2;intj++) { if ( strcmp(broom[inti].name[intj],name) == 0 && broom[inti].intx[intj] == 1 ) { printf ("\t\t%s %d %d %c\n",broom[inti].name[intj],301+inti,intj+1,broom[inti].sex[intj]); break; }
#include <stdio.h>#include <string.h>#include<windows.h>#define N 5struct room{ char name[2][20]; char sex[2]; int intx[2],roomnum;};
struct room broom[N] = { {{" "," "},{' ',' '},{0,0},301},{{" "," "},{' ',' '},{0,0},302}, {{" "," "},{' ',' '},{0,0},303},{{" "," "},{' ',' '},{0,0},304}, {{" "," "},{' ',' '},{0,0},305} };void checkin();void checkout();void lookfor();void main(void){ int intj=0; while (intj != 4)//主菜单 { printf("\t\tPlease Select:\n\t\t1.Check In\n\t\t2.Check Out\n\t\t3.Search\n\t\t4.Exit\n\t\tPlease Select a Task:"); scanf("%d",&intj); if ( intj == 1 ) { checkin(); } else if ( intj == 2) { checkout(); } else if ( intj == 3) { lookfor(); } else if ( intj == 4 ) { char ch; printf("\t\tAre You Sure?(Y/N):"); getchar(); ch = getchar(); if ( ch != 'Y' && ch != 'y') { intj = 0; } } else { printf ("\t\tWarning : Wrong Task! Please Select Again\n"); } }}
void checkin()//录入模块 { char name[20],sex,ch; int inti=0,intj=0; printf ("\t\tInput Information(Name sex(F/M)):"); scanf ("%s %c",name,&sex); printf ("\t\tAvailable:\n"); for (inti=0;inti<N;inti++)//查找可用床位 { if (broom[inti].intx[0] != 1 && broom[inti].intx[1] != 1) { printf ("\t\t%d %d\n\t\t%d %d\n",301+inti,1,301+inti,2); intj++; } else if (broom[inti].intx[0] == 1 && broom[inti].sex[0] == sex) { printf("\t\t%d %d\n",301+inti,2); intj++; } else if (broom[inti].intx[1] == 1 && broom[inti].sex[1] == sex) { printf ("\t\t%d %d\n",301+inti,1); intj++; } else { ; } } if ( intj == 0 )//录入信息,完成入住 { printf("\t\tNo Bed Left"); system("cls"); } else { int roomnum,bednum;lp1: printf ("\t\tPlease Select Room And bed:"); getchar(); scanf("%d%d",&roomnum,&bednum); if (roomnum > 305 || roomnum < 301 || bednum > 2 || bednum < 1) { printf ("\t\tWrong Room Number Or Bed Number!\n"); goto lp1; } strcpy (broom[roomnum-301].name,name); broom[roomnum-301].intx = 1; broom[roomnum-301].sex = sex; printf ("\t\tSucceed\n\t\tContinue Checking In?(Y/N):"); getchar(); ch = getchar(); if ( ch == 'Y' || ch == 'y' ) { system("cls"); checkin(); } system("cls"); }}void checkout()//注销 { char name[20],ch; int inti=0,intj=0,intx=0; printf ("\t\tPlease Input Name:"); getchar(); gets(name); for (inti=0;inti<N;inti++) { for (intj=0;intj<2;intj++) { if ( strcmp(broom[inti].name[intj],name) == 0 ) { intx = 1; break; } } if ( intx == 1 ) { break; } } printf ("\t\tAre You Sure?(Y/N)"); ch=getchar(); if ( ch == 'Y' || ch == 'y' ) { broom[inti].intx[intj] = 0; printf ("\t\tSucceed"); } system("pause"); system("cls"); }void lookfor()//查找住客 { int inti = 0,intj = 0;lp2: printf ("\t\t1.By Name\n\t\t2.By Roomnumber\n\t\tPlease select:");//选择查找方式 scanf ("%d",&inti); if ( inti > 2 || inti < 1) { printf ("\t\tWrong Number!\n"); goto lp2; } if ( inti == 1 )//根据姓名查找 { char name[20]; printf("\t\tPlease Input Name:"); getchar(); gets(name); for (inti=0;inti<N;inti++) { for (intj=0;intj<2;intj++) { if ( strcmp(broom[inti].name[intj],name) == 0 && broom[inti].intx[intj] == 1 ) { printf ("\t\t%s %d %d %c\n",broom[inti].name[intj],301+inti,intj+1,broom[inti].sex[intj]); break; }