본문 바로가기
💻 문제풀고 정리하기 +/백준

[백준 Java] 2525: 오븐 시계

by 종이빨대 2023. 8. 29.
TOP

목차

    1. 문제

    2. 맞춘코드

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.IOException;
    import java.util.StringTokenizer;
    
    public class bj2525{
    	public static void main(String[] args) throws IOException {
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    		StringTokenizer st = new StringTokenizer(br.readLine()," ");
    
    		int h, m, sum_m, total, c_h, c_m;
    
    		h = Integer.parseInt(st.nextToken());
    		m = Integer.parseInt(st.nextToken());
    		sum_m = Integer.parseInt(br.readLine());
    
    		total = h*60 + m;
    		total +=sum_m;
    		
    		if(total>=24*60) total -= (24*60);
    
    		c_h = total/60;
    		c_m = total%60;
    
    		System.out.printf("%d %d", c_h, c_m);
    	}
    }