#include <stdio.h>
#include <malloc.h>
#include <Windows.h>
struct Room {
int num;
int playerId[6];
int max;
};
Room* r = (Room*)malloc(sizeof(Room) * 3);
int select;
int Id;
void Reset() {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 3; j++) {
r[j].playerId[i] = 0;
r[j].max = 0;
}
}
}
void SelectRoom() {
printf("입장할 방번호입력:");
scanf_s("%d", &select);
while (select < 1 || 3 < select) {
printf("잘못된 입력 다시입력!\n");
scanf_s("%d", &select);
}
if (r[select - 1].max <= 5) {
printf("아이디 입력:");
scanf_s("%d", &Id);
system("cls");
r[select - 1].playerId[r[select - 1].max] = Id;
r[select - 1].max++;
}
else {
system("cls");
printf("입장이 불가능 합니다!\n");
}
}
void Show() {
int pCount = 1;
printf("1번방\t\t\t\t\t2번방\t\t\t\t\t3번방\t\t\t\t\n");
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 3; j++) {
if (r[j].playerId[i] != NULL) {
printf("%d번 플레이어: %-20d", pCount, r[j].playerId[i]);
pCount++;
}
else { printf(" "); }
}
printf("\n");
}
}
int main() {
Reset();
while (true) {
SelectRoom();
Show();
}
}