[ 다먹살 ]/- Coding
[백준] 10871 X보다 작은 수
엉망으로살기
2021. 9. 17. 10:46
반응형
https://www.acmicpc.net/problem/10871
10871번: X보다 작은 수
첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다.
www.acmicpc.net
매우 간단한 문제였다. if 카테고리도 빨리 해결할 수 있을 것 같다.
문제 및 입출력
코드
import java.util.*; | |
public class Main | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
int x = sc.nextInt(); | |
int[] arr = new int[n]; | |
for(int i=0; i<n; i++) | |
{ | |
int temp = sc.nextInt(); | |
if(temp<x) | |
{ | |
System.out.print(temp + " "); | |
} | |
} | |
} | |
} |
반응형