happy coding

[java] 10871. x보다 작은 수 - scanner 본문

coding study/baekjoon

[java] 10871. x보다 작은 수 - scanner

yeoonii 2023. 7. 21. 02:14
import java.io.*;
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]; //크기가 n개인 배열 생성

        for (int i=0;i<arr.length;i++) {
            arr[i] = sc.nextInt();  //배열안에 둘째 줄 숫자 저장
            if (arr[i]<x) {
                System.out.printf(arr[i] + " ");
            }
        }
    }
}

'coding study > baekjoon' 카테고리의 다른 글

[java] 2743.단어 길이 재기  (0) 2023.07.21
[java] 11654.아스키코드  (0) 2023.07.21
[java] 2738. 행렬 덧셈  (0) 2023.05.19
[java] 10807.개수 세기  (0) 2023.04.10
[java] 10871.배열  (0) 2023.04.08
Comments