C++
입력된 arr의 수와 일치하는 수를 가진 apt의 층 수 출력
2sac
2024. 9. 30. 15:21
층수는 육안으로 아래부터 1층임.
ex) apt[4][0] 1층
#include <iostream>
#include <cstring>
using namespace std;
int apt[5][3] = {
{15, 18, 17},
{4, 6, 9},
{10, 1, 3},
{7, 8, 9},
{15, 2, 6}
};
int arr[3];
int isPattern(int y) {
if (apt[y][0] == arr[0] && apt[y][1] == arr[1] && apt[y][2] == arr[2]) {
return 1;
}
return 0;
}
int main() {
cin >> arr[0];
cin >> arr[1];
cin >> arr[2];
int chk, l,y,x;
for (y = 0; y < 5; y++) {
if (arr[0] == apt[y][0]) {
chk = isPattern(y);
if (chk == 1) {
cout << 5 - y << "층";
break;
}
} if (arr[0] == apt[y][0]) break;
}
return 0;
}