SWEA

[SWEA] 시각 덧셈

itsnot4me 2024. 9. 27. 22:15

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PttaaAZIDFAUq&categoryId=AV5PttaaAZIDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=2

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		int T;
		T=sc.nextInt();

		for(int test_case = 1; test_case <= T; test_case++)
		{
			int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            int e = a+c;
            int f = b+d;
			if(f>=60){
                f=f-60;
                e=e+1;
            }
            if(e>12){
                e=e-12;
            }
           System.out.println("#"+test_case+" "+e+" "+f);
		
		}
	}
}

 

분 더한게 60 넘기면 시로 1 넘겨주고, 시가 13으로 넘어가면 12 빼 줘서 12시간단위로 만드는 것 외에 크게 어려운 점은 없다

'SWEA' 카테고리의 다른 글

[SWEA] 쉬운 거스름돈  (0) 2024.09.30
[SWEA] 스도쿠 검증  (0) 2024.09.30
[SWEA] 조교의 성적 매기기  (0) 2024.09.26
[SWEA] 중간 평균값 구하기  (2) 2024.09.26
[SWEA] 지그재그 숫자  (1) 2024.09.26