백준 5597번 : 과제 안 내신 분..? | 자바 풀이

박지윤·2022년 7월 17일
0

Algorithm_Implementation

목록 보기
12/16

[ Solution ]

import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {

        Scanner sc = new Scanner(System.in);
        int [] check = new int [31];

        for(int i = 1; i <= 30; i++){
            check[i] = 0;
        }

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

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

check 배열을 만들어서 check 되지 않은 인덱스를 찾아 출력해주면 되는 간단한 문제이다.

0개의 댓글