말랑한 하루

[SW Expert Academy] 1976 시각 덧셈 [Java] 본문

문제풀이/SWexpert Academy

[SW Expert Academy] 1976 시각 덧셈 [Java]

지수는말랑이 2021. 1. 21. 21:47
반응형


[ 핵심풀이 ]

 

Calendar Class 참고하기

github.com/Jisup/TIL/blob/main/Java/Calendar%20Class.md


[ 핵심소스 ]

[ Java ]

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int tc=sc.nextInt();
        for(int t=1;t<=tc;t++) {
            int hour = sc.nextInt();
            int minute = sc.nextInt();
            hour+=sc.nextInt();
            minute+=sc.nextInt();
			
            hour+=minute/60;
            minute%=60;
            hour=hour%12;
            if (hour==0) hour=12;
			
            System.out.println("#"+t+" "+hour+" "+minute);
        }
    }
}
반응형
Comments