happy coding

[java] 10871.배열 본문

coding study/baekjoon

[java] 10871.배열

yeoonii 2023. 4. 8. 22:34
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(st.nextToken());
        int x = Integer.parseInt(st.nextToken());
        //배열 생성
        int[] arr = new int[n];

        st = new StringTokenizer(br.readLine());
        for (int i=0;i<n;i++) {
            //다음주에 받은 숫자를, 배열에 넣기
            arr[i] = Integer.parseInt(st.nextToken());
            //x보다 작은 수만 골라 출력하기
            if (arr[i]<x) {
                bw.write(arr[i] + " ");
            }
        }
        br.close();
        bw.flush();
    }
}

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

[java] 2738. 행렬 덧셈  (0) 2023.05.19
[java] 10807.개수 세기  (0) 2023.04.10
[java] 10951.a+b-4  (0) 2023.04.05
[java] 10952.a+b-5  (0) 2023.04.05
[java] 8393.합구하기  (0) 2023.04.04
Comments