풀이)
간단한 시간 계산 문제로, 시와 분을 따로 계산하기 위해 두번째 줄 입력을 60으로 나눠 시, 분 변수를 따로 설정한다.
첫 줄에 입력받은 시, 분 변수와 계산한 시 분 변수를 더하고, 60과 24를 기준으로 재 계산한다.
내 코드)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String[]args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String[] input= bf.readLine().split(" ");
int h = Integer.parseInt(input[0]);
int m = Integer.parseInt(input[1]);
int time = Integer.parseInt(bf.readLine());
int tHour = time / 60;
int tMinute = time % 60;
int hNew = h + tHour;
int mNew = m + tMinute;
if(mNew >= 60) {
mNew -= 60;
hNew += 1;
}
if(hNew >=24) {
hNew -= 24;
}
System.out.printf("%d %d\n", hNew, mNew);
}
}