Hide

Problem E
Math Worksheet

You are an elementary school student and you have been asked to solve a bunch of simple problems. You have to report your results in a nice pretty table. Of course, being a budding computer scientists, you are not going to solve these problems yourself; you are going to get a machine to do it for you.

Input

Input consists of up to 100 test cases. Each starts with a number $1 \leq n \leq 50$ giving the number of math problems in the test case. The next $n$ lines each contain a math problem of the form $x + y$, $x - y$ or $x * y$. All values for $x$ and $y$ are integers in the range $[-10000,10000]$. The end of all test cases is marked with a value of zero for $n$.

Output

For each test case, print a table of the results, with individual values right justified in their fields. Your results should be printed in row major order with a single space between each pair of adjacent output columns. The number of columns should be chosen to be as large as possible without exceeding a line length of 50 characters. All field widths within a test case should be the same and should be chosen to be large enough to accommodate the longest result in the table. Do not print any trailing spaces. Output one blank line between the the outputs for adjacent test cases.

Sample Input 1 Sample Output 1
7
9999 * 2000
10 - 5
1 + 1
3 - 3
2 * -4
3 * 3
18 + 23
4
3 - 2
1 * 1
2 + -1
4 * 4
0
19998000        5        2        0       -8
       9       41

 1  1  1 16

Please log in to submit a solution to this problem

Log in