✏️ 문제풀이/백준

[백준/Java] 2884번 :: 알람 시계

bono-hye 2023. 10. 1. 21:12

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String strTemp = br.readLine();
		
		StringTokenizer st = new StringTokenizer(strTemp, " ");
		int H = Integer.parseInt(st.nextToken());
		int M = Integer.parseInt(st.nextToken());
		
		
		if (M < 45)
		{
			H--;
			M = 60 - (45 - M);

			if (H < 0)
				H = 23;
			System.out.print(H + " " + M);
		}	
		else
		{
			M = M -45;
			System.out.print(H + " " + M);
		}
	}
}