飞机座位

来源:互联网 发布:派拉软件 编辑:程序博客网 时间:2024/04/28 04:33
#include<stdio.h>int main() {    int a;    int fSeat=0, eSeat=5;    int fc[5] = { 0 }, ec[5] = { 0 };    int flag=1,count;    int i;    char choose;    for (count = 0; count <= 10 && flag == 1; count++) {        printf("Please type 1 for ""first class""\nPlease type 2 for ""economy""\n");        scanf_s("%d", &a);//choose from F&E        if (a == 1) {            if (fc[0] == 1 && fc[1] == 1 && fc[2] == 1 && fc[3] == 1 && fc[4] == 1) {                printf("Would you like to sit in economy section(y or n) ?");                scanf_s(" %c", &choose);                if (choose == 'y') {                    a = 2;                }                else {                    printf("Next flight leaves in 3 hours.\n");                    flag = 0;                }            }            if (flag == 1&&a==1) {                fc[fSeat] = 1;                printf("Your seat assignment is %d\n", fSeat + 1);                fSeat++;            }        }        if (a == 2) {            if (ec[0] == 1 && ec[1] == 1 && ec[2] == 1 && ec[3] == 1 && ec[4] == 1) {                printf("Would you like to sit in first class section(Y or N) ?");                scanf_s("%c\n", &choose);                if (choose == 'Y') {                    a = 1;                }                else {                    printf("Next flight leaves in 3 hours.\n");                    flag = 0;                }            }            if (flag == 1) {                ec[eSeat-5] = 1;                printf("Your seat assignment is %d\n", eSeat + 1);                eSeat++;            }        }        /*if (fSeat > 5 || eSeat > 10)        {            flag == 0;        }*/    }    return 0;}
原创粉丝点击