PROGRAMMING:Annual assessment of table tennis clubs
A table tennis club has two groups A and B. Among them, group A is the main player, undertaking the task of external competition; Group B is a reserve team, mainly training.
The framework of the base class is given below
class Group
{
protected:
string name;// full name
public:
virtual void display()=0;// Show assessment results
}
Taking group as the base class, three classes, GroupA and groupb, are constructed.
Generate the above class and write the main function, which requires a base class group pointer array with no more than 20 elements.
Group *pg[20];
The main function creates GroupA and groupb objects according to the input information.
Input format: each test case occupies one line, the first item is type, a is GroupA, B is groupb, the second item is the name of the athlete, for GroupA, the third item is the total number of victories, and the fourth item is the total number of failures. For groupb, the next is the test results (no more than five). Enter 0 to end the input.
It is required to output the name, group and score of the athlete. For GroupA, the total score is: 2 * winning games - losing games. For groupb, the total score is: number of games won - number of games lost.
Input example:
A Tom 20 3
B Jack 4:2 3:4 4:0 1:4
A Jim 15 9
A John 10 11
B Tony 4:1 0:4 4:3 4:3 4:2
B Li 3:2
0
Output sample
Tom A 37
Jack B 2
Jim A 21
John A 9
Tony B 3
Li B 1
answer:If there is no answer, please comment
The framework of the base class is given below
class Group
{
protected:
string name;// full name
public:
virtual void display()=0;// Show assessment results
}
Taking group as the base class, three classes, GroupA and groupb, are constructed.
Generate the above class and write the main function, which requires a base class group pointer array with no more than 20 elements.
Group *pg[20];
The main function creates GroupA and groupb objects according to the input information.
Input format: each test case occupies one line, the first item is type, a is GroupA, B is groupb, the second item is the name of the athlete, for GroupA, the third item is the total number of victories, and the fourth item is the total number of failures. For groupb, the next is the test results (no more than five). Enter 0 to end the input.
It is required to output the name, group and score of the athlete. For GroupA, the total score is: 2 * winning games - losing games. For groupb, the total score is: number of games won - number of games lost.
Input example:
A Tom 20 3
B Jack 4:2 3:4 4:0 1:4
A Jim 15 9
A John 10 11
B Tony 4:1 0:4 4:3 4:3 4:2
B Li 3:2
0
Output sample
Tom A 37
Jack B 2
Jim A 21
John A 9
Tony B 3
Li B 1
answer:If there is no answer, please comment