1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); // hour를 입력 int b = scan.nextInt(); // minute을 입력 scan.close(); if(b<45) { // 0 ~ 44분일 경우 b = (b + 60) - 45; // a -= 1; // a = a - 1; if(a==-1) { // 0시에서 -1시가 되는 것을 방지 a = 23; } } else { // 45 ~ 59분일 경우 b -= 45; } System.out.printf("%d %d", a, b); } } | cs |
'Algorithm > 백준' 카테고리의 다른 글
백준 2480 (주사위 세개) (0) | 2022.06.23 |
---|---|
백준 2525 (오븐 시계) (0) | 2022.06.22 |
백준 1152 (단어의 개수) (0) | 2022.06.19 |
백준 2754 (학점 계산) (0) | 2022.06.19 |
백준 2744 (대소문자 바꾸기) (0) | 2022.06.19 |