- 문제
- 풀이
#include <iostream>
using namespace std;
int main()
{
int N = 0, X = 0, input = 0;
cin >> N >> X;
for (int i = 0; i < N; i++)
{
cin >> input;
if (input < X)
{
cout << input << " ";
}
}
return 0;
}
- 다시 풀기 (2024-10-28)
#include <iostream>
using namespace std;
int n, x, input;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> x;
for (int i = 0; i < n; i++)
{
cin >> input;
if (input < x)
{
cout << input << ' ';
}
}
return 0;
}
- 다른 풀이 (출처 : https://blog.encrypted.gg/923)
#include <bits/stdc++.h>
using namespace std;
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
int n, x, t;
cin >> n >> x;
while(n--){
cin >> t;
if(t < x) cout << t << ' ';
}
}
'코딩테스트 > 문제풀이' 카테고리의 다른 글
[백준/4949번/C++] 균형잡힌 세상 (0) | 2024.07.10 |
---|---|
[백준/10773번/C++] 제로 (0) | 2024.06.02 |
[백준/10869번/C++] 사칙연산 (0) | 2024.04.30 |
[백준/10171번/C++] 고양이 (0) | 2024.04.28 |
[백준/9498번/C++] 시험 성적 (0) | 2024.04.27 |