본문 바로가기

코딩테스트/백준

[백준-자바] 2525번 오븐 시계 / 2022.02.18

728x90

 

https://www.acmicpc.net/problem/2525

 

2525번: 오븐 시계

첫째 줄에 종료되는 시각의 시와 분을 공백을 사이에 두고 출력한다. (단, 시는 0부터 23까지의 정수, 분은 0부터 59까지의 정수이다. 디지털 시계는 23시 59분에서 1분이 지나면 0시 0분이 된다.)

www.acmicpc.net

 

 

 

import java.util.Scanner;

public class Main {
    public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt(); // 현재 시간
    	int B = sc.nextInt(); // 분
    	int C = sc.nextInt(); // 요리하는 데 필요한 시간
    	
    	for(int i=1; i<=C; i++) {
    		B++;
    		if(B>59) {
    			B=0;
    			A++;
    			if(A>23) {
    				A=0;
    			}
    		}
    	}
    	System.out.println(A+" "+B);
    }
}

 

728x90