PROGRAMMING:Time simulation
The framework of the base class time is given as follows:
class Time
{
protected:
int second;
int minute;
int hour;
public:
void operator++();
void operator--();
}
Create a derived class time_ 12hours, which is used to represent the time in the decimal system. The following member data are added:
string type;// The identification is 12 base time, type = "12 hours time"
string interval;// Mark as am or PM, interval = "am" or interval = "PM"
Add the following member functions:
void operator++();
void operator--();
Create a derived class time_ 24hours, which is used to represent the 24-ary time, and add the following member data:
string type;// The identification is 24 base time, type = "24 hours time"
Add the following member functions:
void operator++();
void operator--();
Generate the above class and write the main function, according to the input initial time information, self increasing or self decreasing type, self increasing or self decreasing times, output its final time information.
Input format: the test input contains multiple test cases, one test case is a line, each line has five digits, the first digit is hexadecimal, 121 means 12 am time, 122 means 12 pm time, 24 means 24 hexadecimal time, the second digit is hour, the third digit is minute, and the fourth digit is second, The fifth character is the operation type, + means self increasing, - means self decreasing, the sixth number is the operation times, and 0 means the end of the test case.
Input example:
121 11 59 59 + 3
24 11 59 59 + 3
122 11 59 59 + 3
122 00 00 00 - 3
121 00 00 00 - 5
24 00 00 00 - 1
0
Output example:
PM 00:00:02
12:00:02
AM 00:00:02
AM 11:59:57
PM 11:59:55
23:59:59
answer:If there is no answer, please comment
class Time
{
protected:
int second;
int minute;
int hour;
public:
void operator++();
void operator--();
}
Create a derived class time_ 12hours, which is used to represent the time in the decimal system. The following member data are added:
string type;// The identification is 12 base time, type = "12 hours time"
string interval;// Mark as am or PM, interval = "am" or interval = "PM"
Add the following member functions:
void operator++();
void operator--();
Create a derived class time_ 24hours, which is used to represent the 24-ary time, and add the following member data:
string type;// The identification is 24 base time, type = "24 hours time"
Add the following member functions:
void operator++();
void operator--();
Generate the above class and write the main function, according to the input initial time information, self increasing or self decreasing type, self increasing or self decreasing times, output its final time information.
Input format: the test input contains multiple test cases, one test case is a line, each line has five digits, the first digit is hexadecimal, 121 means 12 am time, 122 means 12 pm time, 24 means 24 hexadecimal time, the second digit is hour, the third digit is minute, and the fourth digit is second, The fifth character is the operation type, + means self increasing, - means self decreasing, the sixth number is the operation times, and 0 means the end of the test case.
Input example:
121 11 59 59 + 3
24 11 59 59 + 3
122 11 59 59 + 3
122 00 00 00 - 3
121 00 00 00 - 5
24 00 00 00 - 1
0
Output example:
PM 00:00:02
12:00:02
AM 00:00:02
AM 11:59:57
PM 11:59:55
23:59:59
answer:If there is no answer, please comment