본문 바로가기

취업준비 - 코테 , 면접/알고리즘(코테) 공부

백준 2884번 (조건문)

 

 

(풀이) 

 

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int H = in.nextInt(); // 시
        int M = in.nextInt(); // 분

        if(M < 45) {
            H--;      // 시(hour) 1 감소
            M= 60 - (45 - M);  // 분(min) 감소
            if(H < 0) {
                H = 23;
            }
            System.out.println(H + " " + M);
        }
        else {
            System.out.println(H + " " + (M - 45));
        }
    }
}