Notice
Recent Posts
Recent Comments
Link
«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

이것저것

C언어 swea 1976 시각 덧셈 본문

Language/C언어

C언어 swea 1976 시각 덧셈

olivia-com 2020. 11. 19. 22:17

https://swexpertacademy.com/main/identity/anonymous/loginPage.do

 

SW Expert Academy

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

swexpertacademy.com

#include <stdio.h>

int main(void){
	int test_case,i;
	int h1, h2, m1, m2;
	scanf("%d", &test_case);
	for(i = 0; i< test_case; i++){
		scanf("%d %d %d %d", &h1, &m1, &h2, &m2); 
		// 시 분으로 이루어진 시각 2개 입력받기 
		int minute = m1 + m2;
		int hour = h1 + h2;
		if(minute >= 60){
			// minute 이60 이상이면 1시간 추가 
			minute %= 60;
			hour++;
		}
		hour = hour > 12 ? hour % 12 : hour;
		// hour이 12 초과면 hour은 12로 나눴을 때의 나머지 
		printf("#%d %d %d\n", i+1, hour, minute);
	}
	return 0;
} 
​

'Language > C언어' 카테고리의 다른 글

C언어 swea 2001 파리퇴치  (0) 2020.11.19
C언어 swea 1966 숫자를 정렬하자  (0) 2020.11.19
C언어 swea 1926 간단한 369게임  (0) 2020.11.19
C언어 swea 1284 수도 요즘 전쟁  (0) 2020.11.19
이진 체계 정리  (0) 2020.11.19