CodingTest/백준
[c++] 백준 - 5597번: 과제 안 내신 분..?
Daybreak21
2023. 4. 11. 21:34
로그인
www.acmicpc.net
#include <iostream>
using namespace std;
int main() {
int number;
bool student[30];
for (int i = 0; i < 30; i++) student[i] = 1;
for (int i = 0; i < 28; i++) {
cin >> number;
student[number - 1] = 0;
}
for (int j = 0; j < 30; j++) {
if (student[j]) cout << j + 1 << endl;
}
return 0;
}
student배열을 bool타입으로 선언하고 풀었다. 숫자가 들어오면 index를 false로 바꿔줘서 안낸사람을 출력하는 반복문에서 제외시켜주었다.