백준/기초

[백준][for 문] 10871번 X보다 작은 수

Snowboarder 2022. 2. 25. 21:40

문제접근

  • for 문 사용
  • 리스트 출력할 수 있는가 조건에 따른

문제풀이

내풀이

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 = " ")

다른사람풀이

a,b = map(int,input().split())
score = [x for x in input().split() if int(x)<b]
print(' '.join(score))

숏코딩

n,x,*a=map(int,open(0).read().split())
for i in a:i<x!=print(i)

'백준 > 기초' 카테고리의 다른 글

[백준][while 문] A+B - 4  (0) 2022.02.28
[백준][while문] 10952번 A + B - 5  (0) 2022.02.28
[백준][for 문] 2439번 별 찍기 - 2  (0) 2022.02.25
[백준][for 문] 2438번 별찍기 - 1  (0) 2022.02.25
[백준][for 문] 11022번 A+B - 8  (0) 2022.02.25