본문 바로가기

[BOJ] - JAVA

[백준] 2884 : 알람 시계 JAVA 풀이

 

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--;
            M=M+15;
            if(H<0){
                H=23;
            }
            System.out.println(H+" "+M);
        }
        else{
            System.out.println(H+" "+(M-45));
        }
    }
}