백준 #2884번 알람 시계

jhj·2024년 2월 18일

백준 JAVA

목록 보기
382/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int h = sc.nextInt();
		int m = sc.nextInt();
		int outputH, outputM;
		
		if(m >= 45) {
			outputH = h;
			outputM = m - 45;
		}else {
			outputM = 60 - (45 - m);
			if(h == 0) {
				outputH = 23;
			}else {
				outputH = h - 1;
			}
		}
		
		System.out.println(outputH + " " + outputM);
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글