[BOJ/C++] 2884 알람 시계

Hanbi·2022년 4월 4일
0

Problem Solving

목록 보기
10/105
post-thumbnail

문제

https://www.acmicpc.net/problem/2884

풀이

입력 받을 때 0 -> 24
출력 할 때 24 -> 0

코드

#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>

using namespace std;

int main(void) {
	int h, m;
	int time;
	
	cin >> h;
	if(h == 0) {
		h = 24;
	}
	cin >> m;
	
	time = 60 * h + m;
	time = time - 45;
	
	h = time / 60;
	if(h == 24) {
		h = 0;
	}
	m = time % 60;
	
	printf("%d %d", h, m);
	
	return 0;
}
profile
👩🏻‍💻

0개의 댓글