-
[java]백준 알람 시계 2884번알고리즘 문제풀이/백준(자바) 2023. 3. 31. 21:36
코드
import java.util.Scanner; public class BOJ_2884 { public static void main(String[] args) { Scanner in =new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt(); if(b<45){ //b가45보다 작다면 //시에서 분으로 추가(+60) if(a==0){ //a(24)가 0이면 //a=24-1 //b에 60분 추가 a=23; b=b+60; }else{ // 0아니면 //a=24-1 //b에 60분 추가 a=a-1; b=b+60; } } System.out.println(a+" "+(b-45)); in.close(); } }
링크
https://www.acmicpc.net/problem/2884
'알고리즘 문제풀이 > 백준(자바)' 카테고리의 다른 글
[java]백준 고양이 10171번 (0) 2023.04.02 [java]백준 개 10172번 (0) 2023.04.01 [java]백준 사분면 고르기 14681번 (0) 2023.03.30 [java]백준 오븐 시계 2525번 (0) 2023.03.29 [java]백준 학점계산 2754번 (0) 2023.03.28