공부기록/SWEA

[SWEA] 1976번 시각 덧셈

메델 2023. 10. 19. 10:03
import java.util.Scanner;

public class Solution {
	
    public static void main(String[] args) {
    	Scanner kb = new Scanner(System.in);
    	
    	int n = kb.nextInt();
    	
    	for(int i=0; i<n; i++) {
    		int h1 = kb.nextInt();
    		int m1 = kb.nextInt();
    		int h2 = kb.nextInt();
    		int m2 = kb.nextInt();
    		
    		int resultH = h1+h2;
    		int resultM = m1+m2;
    		
    		if(resultM>=60) {
    			resultM = (m1+m2)%60;
    			resultH++;
    		}
    		
    		if(resultH>12) {
    			resultH = resultH%12;
    			if(resultH == 0) {
    				resultH = 12;
    			}
    		}
    		
    		System.out.println("#"+(i+1)+" "+resultH+" "+ resultM);
    		
    	}

    }
}