Doing/C&C++
2차원 극장 예매 시스템
YongArtist
2016. 11. 30. 15:27
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | __author__ = "introfor"; /* history: 2016/11/30 Starting two-dimensions theater reservation system. Finished. */ #include <stdio.h> #define SIZE 10 int main() { char c = 0; int weight = 0, height = 0; int theater[SIZE][SIZE] = { 0 }; while (1) { printf("극장 좌석 예약 하시겠습니까?(y/n)"); scanf_s("%c", &c); if (c == 'y') { printf("예매가능좌석\n\n"); printf(" 1 2 3 4 5 6 7 8 9 10\n"); printf(" -----------------------------\n"); for (int i = 0; i < SIZE; i++) { printf("%2d|", i + 1); for(int j=0;j<SIZE;j++) printf(" %d ", theater[i][j]); printf("\n"); } printf("\n예약좌석번호를 입력하세요:"); scanf_s("%d %d", &weight,&height); if (weight <= 0 || weight > SIZE) { printf("1~10 사이의 숫자를 입력해주세요"); continue; } if (theater[weight - 1][height - 1] == 0) { theater[weight - 1][height - 1] = 1; printf("예약되었습니다.\n"); } else printf("이미 예약되어있습니다. 다른 좌석을 선택해주세요.\n"); while ((c = getchar()) != '\n'&&c != EOF); } else if (c == 'n') return 0; } return 0; } | cs |