Python/BOJ
[Python] 백준 10871 : X보다 작은 수
Holywat2r
2021. 8. 21. 12:18
https://www.acmicpc.net/problem/10871
10871번: X보다 작은 수
첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다.
www.acmicpc.net
n , x = map(int, input().split())
a = list(map(int,input().split()))
for i in range(n):
if a[i] < x:
print(a[i], end =' ')
코드 풀이
n , x = map(int, input().split()) # 비교할 개수 n, 기준 값 x 입력 받기
a = list(map(int,input().split())) # a를 list로 설정하여 입력값 받기
for i in range(n):
if a[i] < x: # 입력한 a[i] 의 값이 기준값 x 보다 작을경우
print(a[i], end =' ') # a[i] 출력