[Java]
1. Scanner 이용
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int H = sc.nextInt();
int M = sc.nextInt();
if(M < 45){
M = 60 - (45 - M);
if(H == 0){
H = 23;
} else{
H--;
}
System.out.print(H + " " + M);
} else {
System.out.print(H + " " + (M - 45));
}
sc.close();
}
}
2. BufferedReader 이용
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));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int H = Integer.parseInt(st.nextToken());
int M = Integer.parseInt(st.nextToken());
if(M >= 45){
M = M - 45;
} else{
M = 60 - (45 - M);
if(H == 0){
H = 23;
} else{
H--;
}
}
System.out.print(H + " " + M);
br.close();
}
}
[Javascript]
const input = require('fs').readFileSync('/dev/stdin').toString().trim().split(" ").map(Number);
H = input[0];
M = input[1];
if(M >= 45){
M -= 45;
} else{
M = 60 - (45 - M);
if(H === 0){
H = 23;
} else{
H -= 1;
}
}
console.log(H, M);
[Python]
H, M = map(int, input().split())
if M >= 45 :
print(H, M-45)
else :
M = 60 - (45 - M)
if H == 0 : H = 23
else : H = H-1
print(H, M)