[SWEA] 1976 시각 덧셈

Time Lapse :10min 0sec

1976.cpp

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
#include <iostream>
using namespace std;
int main(void)
{
int tc;
cin >> tc;
int t2, m2;
int at, am;
bool flag;
for (int i = 1; i <= tc; i++) {
cin >> at >> am >> t2 >> m2;
flag = false;
am += m2;
if (am >= 60) {
flag = true;
am -= 60;
}
at += t2;
if (flag)
++at;
if (at >= 13)
at -= 12;
cout << "#" << i << " " << at << " " << am << endl;
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/1976/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.