-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path488.cpp
77 lines (44 loc) · 707 Bytes
/
488.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
using namespace std;
class Clock
{
public:
Clock(int h, int m, int s);
void ShowTime()
{
cout << "Now:" << hour << ":" << minute << ":" << second << endl;
}
private:
int hour;
int minute;
int second;
};
void ck(int &x,const int mx){
if(x>=mx)x=0;
if(x<=0)x=0;
};
Clock::Clock(int h,int m, int s)
{
ck(h,24),ck(m,60),ck(s,60);
hour=h;
minute=m;
second=s;
}
int main()
{
Clock *c1, *c2;
int type;
cin>>type;
switch(type)
{
case 1:
c1 = new Clock(24,24,-1);
c1->ShowTime();
break;
case 2:
c2 = new Clock(5,20,30);
c2->ShowTime();
break;
}
return 0;
}