PROGRAMMING:Data maximum problem (overload + function template)
Two classes are designed as follows: class time has three data members, HH, mm, SS, representing hours, minutes and seconds respectively, and has several constructors and an overloaded - (minus sign) member function. The class date has three data members, year, month and day, representing year, month and day respectively, and has several constructors and a member function overloaded with > (<) (greater than or less than sign).
It is required to design a function template template < < class T > < double maxn (t x [] int len) to return the maximum value for int, float, time, date or other types of data.
The main function has the following data members:
int intArray[100];
double douArray[100]; time timeArray[100];
date dateArray[100];
Among them, HH = 3600 * ss, mm = 60 * ss, year = 365 * day, month = 30 * day. For time and date types, the data is converted to SS or day for operation.
Input format:
Each line has one operation. The first number of each line is the element type. 1 is the integer element, 2 is the floating-point element, 3 is the time type, and 4 is the date type. If it is an integer element, then enter the integer data and end with 0. For floating-point elements, enter floating-point data, ending with 0. If it is a time type element, enter time type data (hH1 MM1 SS1 HH2 mm2ss2) to end with 0. For date type data, enter date type data (year1 month1 Day1 year2 month2 Day2), ending with 0. Enter - 1 to indicate the end of all input.
Output format:
For each input, output a maximum value.
Sample input:
1 4 5 9 3 7 0
2 4.4 5.5 6.9 3.2 2.7 0
3 18 21 22 18 20 31 18 21 49 0
4 2013 5 14 2013 5 15 2013 4 1 0
-1
Sample output:
nine
six point nine
18 21 49
2013 5 15
answer:If there is no answer, please comment
It is required to design a function template template < < class T > < double maxn (t x [] int len) to return the maximum value for int, float, time, date or other types of data.
The main function has the following data members:
int intArray[100];
double douArray[100]; time timeArray[100];
date dateArray[100];
Among them, HH = 3600 * ss, mm = 60 * ss, year = 365 * day, month = 30 * day. For time and date types, the data is converted to SS or day for operation.
Input format:
Each line has one operation. The first number of each line is the element type. 1 is the integer element, 2 is the floating-point element, 3 is the time type, and 4 is the date type. If it is an integer element, then enter the integer data and end with 0. For floating-point elements, enter floating-point data, ending with 0. If it is a time type element, enter time type data (hH1 MM1 SS1 HH2 mm2ss2) to end with 0. For date type data, enter date type data (year1 month1 Day1 year2 month2 Day2), ending with 0. Enter - 1 to indicate the end of all input.
Output format:
For each input, output a maximum value.
Sample input:
1 4 5 9 3 7 0
2 4.4 5.5 6.9 3.2 2.7 0
3 18 21 22 18 20 31 18 21 49 0
4 2013 5 14 2013 5 15 2013 4 1 0
-1
Sample output:
nine
six point nine
18 21 49
2013 5 15
answer:If there is no answer, please comment