PROGRAMMING:Carry and borrow in 2017final
Chen, a sophomore in Fenghu primary school, was surprised to find that the students in the class could be divided into three categories. One could always correctly complete the three digit integer addition and subtraction (GroupA); One is always able to add three digit integers correctly, but for subtraction, it always forgets to process the borrow (groupb); The rest always forget the carry of addition and the borrow of subtraction (Group C).
Now, please give me the answer that the students will give when Mr. Chen asks a question in class.
The implementation is based on the following base class framework
class Group
{
public:
virtual int add(int x, int y)=0;// Output the result of addition
virtual int sub(int x, int y)=0;// Output the result of subtraction
}
Three classes, GroupA, groupb and groupc, are constructed
And write the main function, which requires that there is a base class group pointer array in the main function, through which add and sub operations are carried out uniformly.
###Input format:
First, enter an integer n, which is the number of class, no more than 20.
Next, enter n numbers (the value is 1, 2, or 3), which is the category of each student. The first number is the category of the first student, then the category of the second student,..., and finally the category of the nth student. When the category is 1, it indicates that the student is A-Class; When it is 2, it indicates that the student is of class B, and when it is 3, it indicates that the student is of class C.
Next, enter a mathematical problem on each line. The first part is the number of the student to be asked, which is a positive integer no more than N. 1 is the first student, 2 is the second student, and N is the nth student; The second part is a specific mathematical problem, which may be addition or subtraction. Note: there is no space between the operation object and the plus minus sign. Both operation objects are non negative integers with a maximum of 999. When subtracting, the subtracted is not less than the subtracted.
If a line begins with 0, the question ends.
###Output format:
Output the answer of the given student to the given question.
###Input example:
```in
four
1 2 3 3
1 79+81
2 81-79
4 183+69
0
```
###Output example:
```out
one hundred and sixty
twelve
one hundred and forty-two
```
answer:If there is no answer, please comment
Now, please give me the answer that the students will give when Mr. Chen asks a question in class.
The implementation is based on the following base class framework
class Group
{
public:
virtual int add(int x, int y)=0;// Output the result of addition
virtual int sub(int x, int y)=0;// Output the result of subtraction
}
Three classes, GroupA, groupb and groupc, are constructed
And write the main function, which requires that there is a base class group pointer array in the main function, through which add and sub operations are carried out uniformly.
###Input format:
First, enter an integer n, which is the number of class, no more than 20.
Next, enter n numbers (the value is 1, 2, or 3), which is the category of each student. The first number is the category of the first student, then the category of the second student,..., and finally the category of the nth student. When the category is 1, it indicates that the student is A-Class; When it is 2, it indicates that the student is of class B, and when it is 3, it indicates that the student is of class C.
Next, enter a mathematical problem on each line. The first part is the number of the student to be asked, which is a positive integer no more than N. 1 is the first student, 2 is the second student, and N is the nth student; The second part is a specific mathematical problem, which may be addition or subtraction. Note: there is no space between the operation object and the plus minus sign. Both operation objects are non negative integers with a maximum of 999. When subtracting, the subtracted is not less than the subtracted.
If a line begins with 0, the question ends.
###Output format:
Output the answer of the given student to the given question.
###Input example:
```in
four
1 2 3 3
1 79+81
2 81-79
4 183+69
0
```
###Output example:
```out
one hundred and sixty
twelve
one hundred and forty-two
```
answer:If there is no answer, please comment