Small Grey Outline Pointer baekjoon c++ 10871 X보다 작은 수
본문 바로가기
Dev./Algorithm Prac

baekjoon c++ 10871 X보다 작은 수

by sso. 2022. 3. 20.
#include <stdio.h>

int main() {

	int n, x;
	int a;


	scanf("%d %d", &n, &x);
	
	for (int i = 1; i <= n; i++) {
		scanf("%d ", &a);
		if (a < x) {
			printf("%d ", a);
		}
	} 


}

 

<결과>

10 6
9 8 3 5 2 10 1 4 7 6
3 5 2 1 4

 

x보다 작은 값이 입력된 순서대로 출력된다

 

for와 if문을 같이 사용

728x90

'Dev. > Algorithm Prac' 카테고리의 다른 글

baekjoon c++ 10951 A+B  (0) 2022.03.20
baekjoon c++ 10952 A+B  (0) 2022.03.20
baekjoon c++ 2439 별찍기2  (0) 2022.03.20
baekjoon c++ 2438 별찍기1  (0) 2022.03.20
baekjoon [c++] 2480 :: 주사위 세개  (0) 2022.03.20

댓글