코딩 테스트/백준
[JAVA]백준 2884: 알람 시계
keep it simple
2023. 2. 13. 01:56
https://www.acmicpc.net/problem/2884
2884번: 알람 시계
상근이는 매일 아침 알람을 듣고 일어난다. 알람을 듣고 바로 일어나면 다행이겠지만, 항상 조금만 더 자려는 마음 때문에 매일 학교를 지각하고 있다. 상근이는 모든 방법을 동원해보았지만,
www.acmicpc.net
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int hour = sc.nextInt();
int minutes = sc.nextInt();
int leftMinutes = minutes - 45;
if(leftMinutes < 0){
if(hour == 0){
hour = 23;
}else{
hour = hour - 1;
}
minutes = 60 + leftMinutes;
}else{
minutes = leftMinutes;
}
System.out.println(hour + " " + minutes);
}