728x90
C언어
C언어 기초 극장 예매 시스템
프로파일
byksr1107 ・ 2020. 10. 5. 14:20
URL 복사 통계
#include <stdio.h>
#define SIZE 10
void seatStatus(int a[]);
int main (void)
{
int seat[SIZE] = { 0 };
int menu, tmp;
while (1)
{
printf("\n\n[1] 예약 \t[2] 취소 \t[3] 현황 \t[4] 종료 \n");
printf("메뉴 선택 : ");
scanf_s("%d", &menu);
if (menu == 1)
{
seatStatus(seat);
printf("예약 좌석 번호 : ");
scanf_s("%d", &tmp);
if (seat[tmp - 1] == 1)
{
printf("잘못 선택되었습니다 \n");
}
else
{
seat[tmp - 1] = 1;
}
}
else if (menu == 2)
{
seatStatus(seat);
printf("취소 좌석 번호 : ");
scanf_s("%d", &tmp);
if (seat[tmp - 1] == 0)
{
printf("잘못 선택되었습니다 \n");
}
else
{
seat[tmp - 1] = 0;
}
}
else if (menu == 3)
{
seatStatus(seat);
}
else
break;
}
return 0;
}
void seatStatus(int a[])
{
printf("==========================================================================\n");
printf(" 1 2 3 4 5 6 7 8 9 10\n");
printf("==========================================================================\n");
for (int i = 0; i < SIZE; i++)
{
printf("%6d", a[i]);
}
printf("\n==========================================================================\n");
}
결과
728x90
'개발자 모드 > C언어' 카테고리의 다른 글
C언어 숙박 프로그램 (0) | 2021.03.08 |
---|---|
C언어 자판기 소스코드 (0) | 2021.03.08 |
C언어 초를 받아서 시분초로 표시 (0) | 2021.03.08 |
C언어 기초 야구 게임 (0) | 2021.03.08 |
C언어 카드 뒤집기 게임 (0) | 2021.03.08 |