Notice
Recent Posts
Recent Comments
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

충분히 쌓여가는

백준[Java] 5597번 과제 안 내신 분..? 본문

IT/Java[백준]

백준[Java] 5597번 과제 안 내신 분..?

빌드이너프 2023. 2. 28. 23:08

https://www.acmicpc.net/problem/5597

 

5597번: 과제 안 내신 분..?

X대학 M교수님은 프로그래밍 수업을 맡고 있다. 교실엔 학생이 30명이 있는데, 학생 명부엔 각 학생별로 1번부터 30번까지 출석번호가 붙어 있다. 교수님이 내준 특별과제를 28명이 제출했는데,

www.acmicpc.net

문제풀이 1

import java.util.Scanner;
public class _5597_1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] arr = new int[31];

        for (int i = 1; i <= 28; i++) {
            int check = sc.nextInt();
            arr[check] = 1;

        }

        for (int i = 1; i <= 30; i++) {
            if (arr[i] != 1)
                System.out.println(i);
        }
    }
}

문제풀이 2

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class _5597_2 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int[] arr = new int[31];

        for (int i = 1; i <= 28; i++) {
            int check = Integer.parseInt(br.readLine());
            arr[check] = 1;

        }

        for (int i = 1; i <= 30; i++) {
            if (arr[i] != 1)
                System.out.println(i);
        }
    }
}