1. ๋ด ์ฝ๋
๋ ํด๋์ค๋ก ํ์๋๋ฐ, ์ด๊ฑด ๊ทธ๋ฅ for๋ก ํธ๋ ๊ฒ ๋ ์ง๊ด์ ์ด๊ณ ๋น ๋ฅธ ๋ฏ ํ๋ค...
์์ ๊ฐ๋ ์ผ๋ก ํ์ด์ผ ์ ํผ ๊ฑฐ๋ผ๋ ์๊ฐ์ ๋ฒ๋ฆฌ์.
import java.util.Scanner;
class Solution
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int T;
T=sc.nextInt();
for (int test_case = 1; test_case <= T; test_case++) {
// 1. ๊ฐ์ ์ ๋ถ ๋ค ๋ฐ๊ณ , 1,3๋ฒ / 2,4๋ฒ ๋ฐ๋ก ๊ณ์ฐ
int H1 = sc.nextInt();
int M1 = sc.nextInt();
int H2 = sc.nextInt();
int M2 = sc.nextInt();
// 2. ๋ถ ๋จผ์ ๊ณ์ฐํ๊ณ , ๋ฐํ ๊ฐ์ผ๋ก ์ฌ๋ฆผ ์์ ๋๋จธ์ง๋ฅผ ๋ฐํ
Minute minute = new Minute(M1, M2);
// 3. ์ ๊ณ์ฐ ์ input์ผ๋ก ๋ ์๋ฅผ ๋ํ๋ด๋ ์์ ์ฌ๋ฆผ ์ ๋ฃ๊ธฐ // ๊ฒฐ๊ณผ ๋ฐํ
Hour hour = new Hour(H1,H2, minute.upper);
int refinedH;
if(hour.H>12){
refinedH = hour.H-12;
}else{
refinedH = hour.H;
}
System.out.printf("#%d %d %d\n",test_case,refinedH, minute.rest);
}
}
}
class Minute {
int plusTotal;
int upper;
int rest;
Minute(int a , int b){
this.plusTotal = a+ b;
this.upper = this.plusTotal/60;
this.rest = this.plusTotal - this.upper*60;
}
}
class Hour {
int H;
public Hour(int a, int b, int upper) {
this.H = a+b+upper;
}
}
0