-
Notifications
You must be signed in to change notification settings - Fork 64
/
6.cpp
60 lines (60 loc) · 910 Bytes
/
6.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
using namespace std;
class time
{
private:
int h, m, s;
public:
time()
{
h=0;
m=0;
s=0;
}
time(int a, int b, int c)
{
h=a;
m=b;
s=c;
}
void add(time t1, time t2)
{
s = t1.s + t2.s;
if(s>59)
{
s = s - 60;
m = m+1;
}
m = m + t1.m + t2.m;
if(m>59)
{
m = m - 60;
h++;
}
h = h + t1.h + t2.h;
if(h>12)
{
h = h-12;
}
}
void display()
{
cout << "Time: " << h << ":" << m << ":" << s ;
}
};
int main()
{
int a, b, c;
cin >> a ;
cin >> b ;
cin >> c ;
time T1(a, b, c);
a = b = c = 0;
cin >> a ;
cin >> b ;
cin >> c ;
time T2(a, b, c);
time T3;
T3.add(T1, T2);
T3.display();
}