본문 바로가기
알고리즘풀이/백준-자바

[백준/JAVA] 2884번 알람시계

by 이얏호이야호 2020. 7. 20.

import java.util.Scanner;


public class Main {

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

int result1, result2, hour, minutes, fix = 60,fix2 = 24;


hour = in.nextInt();

minutes = in.nextInt();

minutes = minutes - 45;

if (minutes < 0) {

result2 = fix + minutes;

result1 = --hour;

if(result1 < 0 ) {

result1 = result1 + fix2;

}

} else {

result1 = hour;

result2 = minutes;

}

System.out.println(result1 + " " + result2);

}

}

더 많은 백준 코드가 보고 싶다면 ?  https://chuinggun.tistory.com/category/%EB%B0%B1%EC%A4%80


댓글