본문 바로가기

Algorithm/SWEA

[SWEA] 1976. 시간 덧셈 D2 JAVA

반응형


문제 이해

 

아이디어

 

코드

import java.util.*;

public class Solution {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int T = sc.nextInt();
		for (int tc = 1; tc <= T; ++tc) {
			int h1 = sc.nextInt();
			int m1 = sc.nextInt();
			int h2 = sc.nextInt();
			int m2 = sc.nextInt();
			int h3 = h1 + h2, m3 = m1 + m2;
			while (m3 > 59) {
				m3 -= 60;
				h3++;
			}
			while (h3 > 12) {
				h3 -= 12;
			}
			System.out.printf("#%d %d %d\n", tc, h3, m3);
		}
	}
}

 

 


 

 

집사는개발자가되고파

 

choppadontbiteme.tistory.com

 

반응형