PROGRAMMING:Information management of teachers and students
The following basic class framework is given
class Person
{
protected:
int NO;// No
public:
virtual void display()=0;// Output relevant information
}
Taking person as the base class, student and teacher classes are constructed.
To generate the above class and write the main function, the main function should have a base class person pointer array with no more than 10 elements.
Person *pp[10];
According to the input information, the main function establishes student and teacher class objects. For student, it gives the final scores of 5 courses (integer, fill in - 1 for absent subjects). For teacher, it gives the number of papers published every year in recent 3 years.
Input format: each test case occupies one line, the first item is personnel type, 1 is student, 2 is teacher, the next is number (0-9999), the next is student's score of five courses, and the teacher's number of papers in three years. The last line, 0, indicates the end of the input.
It is required to output the number, the number of absent subjects and the average score of the tested subjects (keep 1 decimal place, when the number of tested subjects is 0, the average score will not be output), and the total number of 3-year papers of the teacher.
Hint: using virtual function to realize polymorphism
Input sample
1 19 -1 -1 -1 -1 -1
1 125 78 66 -1 95 88
2 68 3 0 7
2 52 0 0 0
1 6999 32 95 100 88 74
0
Output sample
19 5
125 1 81.8
68 10
52 0
6999 0 77.8
answer:If there is no answer, please comment
class Person
{
protected:
int NO;// No
public:
virtual void display()=0;// Output relevant information
}
Taking person as the base class, student and teacher classes are constructed.
To generate the above class and write the main function, the main function should have a base class person pointer array with no more than 10 elements.
Person *pp[10];
According to the input information, the main function establishes student and teacher class objects. For student, it gives the final scores of 5 courses (integer, fill in - 1 for absent subjects). For teacher, it gives the number of papers published every year in recent 3 years.
Input format: each test case occupies one line, the first item is personnel type, 1 is student, 2 is teacher, the next is number (0-9999), the next is student's score of five courses, and the teacher's number of papers in three years. The last line, 0, indicates the end of the input.
It is required to output the number, the number of absent subjects and the average score of the tested subjects (keep 1 decimal place, when the number of tested subjects is 0, the average score will not be output), and the total number of 3-year papers of the teacher.
Hint: using virtual function to realize polymorphism
Input sample
1 19 -1 -1 -1 -1 -1
1 125 78 66 -1 95 88
2 68 3 0 7
2 52 0 0 0
1 6999 32 95 100 88 74
0
Output sample
19 5
125 1 81.8
68 10
52 0
6999 0 77.8
answer:If there is no answer, please comment