알고리즘/백준
백준 2525번
hyeonseong
2022. 7. 29. 09:19
풀이
- 시간이 24시간 이상을 넘어가면 0이 된다.
- 분 이 60분 이상이 되면 0
- 입력 받은 시간 / 60 을 시간에 더해준다(+)
- 60으로 나눈 나머지 값을 분에 더해준다(+)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int h = sc.nextInt(); // 시간 입력 0~23
int m = sc.nextInt(); // 분 입력
int c = sc.nextInt(); // 요리하는데 필요한 시간 입력 받기
h += c / 60;
m += c % 60;
if(m >= 60){
h+=1;
m -= 60;
}
if(h >= 24) {
h -= 24;
}
System.out.println(h + " " + m);
}
}