본문 바로가기

알고리즘/백준

알람 시계

#include <iostream>
using namespace std;

int main(void)
{
	int inH = 0;
	int inM = 0;
	int outH = 0;
	int outM = 0;

	cin >> inH;
	cin >> inM;

	if ((inH < 0) || (23 < inH))
		return 0;
	if ((inM < 0) || (59 < inM))
		return 0;

	if ((inH == 0) && (inM < 45))
	{
		outH = 23;
		outM = 15 + inM;
	}

	else
	{
		outH = (60 * inH + inM - 45) / 60;
		outM = (60 * inH + inM - 45) % 60;
	}

	cout << outH<< " " << outM << '\n';
	return 0;
}

'알고리즘 > 백준' 카테고리의 다른 글

구구단  (0) 2019.09.10
세 수  (0) 2019.09.09
윤년  (0) 2019.09.08
시험 성적  (0) 2019.09.08
두 수 비교하기  (0) 2019.09.08