Playground/자바문제집

[백준] 10871번

미숫가루설탕많이 2023. 1. 20. 20:10
import java.util.Scanner;

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];
      String result = "";

      for (int i = 0; i < N; i++) {
         arr[i] = sc.nextInt();
         if (arr[i] < X) {
            if (result == "") {
               result = String.valueOf(arr[i]);
            } else {
               result += " " + arr[i];
            }
         }
      }
      System.out.println(result);
   }
}

'Playground > 자바문제집' 카테고리의 다른 글

[백준] 2562번  (0) 2023.01.20
[백준] 10818번  (0) 2023.01.20
[백준] 10807번  (0) 2023.01.20
[백준] 1152번  (0) 2023.01.20
[백준] 10951번  (0) 2023.01.20