|
Time |
Memory |
| Case 1 |
1 sec |
32 MB |
| Case 2 |
1 sec |
32 MB |
| Case 3 |
1 sec |
32 MB |
| Case 4 |
1 sec |
32 MB |
| Case 5 |
1 sec |
32 MB |
Description
Complete an existed class Clock. There is also had a function named sec2clk(), understand it and use it, it may help.
Clock sec2clk(int s) – Turn s seconds into a clock, and return it. For example:
- s = 3661 => 01:01:01
- s = 86401 => 00:00:01
- s = -1 => 23:59:59
Clock
Private Variables:
- h(unsigned int) represents to hour.
- m(unsigned int) represents to minute.
- s(unsigned int) represents to second.
Constructors:
- Clock(unsigned int _h, unsigned int _m, unsigned int _s) – Should initalize h to _h%24, m to _m%60 and s to _s%60.
Public Methods:
- Clock operator+(const Clock &other) – Should return a Clock which is the addition of the two clocks.
- Clock operator-(const Clock &other) – Should return a Clock which is the subtraction of the two clocks.
Need consider time carry(時間進位) and time overflow(時間溢位). For example:
- 00:59:59 + 00:00:01 = 01:00:00
- 23:59:59 + 00:00:01 = 00:00:00
- 00:00:00 - 00:00:01 = 23:59:59
note that you may use Clock::clk2sec() and sec2clk().
- bool operator>(const Clock &other) – Should return true if the time of clock is bigger than others; otherwise return false.
Need consider time carry(時間進位) and time overflow(時間溢位). For example:
- 01:00:00 > 00:59:59 is true
- 00:00:01 > 23:59:59 + 00:00:01 is true
note that you may use Clock::clk2sec().
- bool operator<(const Clock &other) – Should return true if the time of clock is smaller than others; otherwise return false.
- bool operator>(const unsigned int ui) – Should return true if the total seconds of clock is bigger than ui%86400; otherwise return false.
- bool operator<(const unsigned int ui) – Should return true if the total seconds of clock is smaller than ui%86400; otherwise return false.
- bool operator==(const Clock &other)– Should return true if the time of clock is equal to others; otherwise return false.
- bool operator==(const unsigned int ui) – Should return true if the total seconds of clock is equal to ui%86400; otherwise return false.
- unsigned int clk2sec() const – Calculate the total seconds of clock and return (no need implement).
- friend ostream &operator<<(ostream &os, const Clock &clk) – For print out a Clock variable directly (no need implement).
Input
No need to handle input. (Input would be number 1~5 to represent the index of test-case)
Output
Depend on test case show in main.cpp.
Partial Judge Code
13075.cpp
Partial Judge Header
13075.h
Tags