14502 - Audrey's Perfect Math Class   

Description

Ms. Audrey has something to teach Josh, Vaness, Bill, and you!

As her student, you don't know how to solve her homework

Given Math Equation in prefix form, try to figure out the infix equation with the least amount of necessary parenthesis

Stream Baldi's PERFECT Basics In Education And Learning by airdefence |  Listen online for free on SoundCloud

e.g. given prefix form * - 20 30 50

the infix form will be (20-30)*50

((20-30)*50)is wrong since there is an unnecessary parenthesis

The opreator only consist of +, -,  and *

Input

There will be multiple testcase, each testcase have only 1 line input

Hint: Try to use getline function and char * as the array to scan the string, and scan it until EOF as we don't know the length of the string and how many testcases

Every number shown in the string are in range [0, 9999]

 

Testcase 1-2: only operator +

Testcase 3-4: operator and -

Testcase 5-6: operator +-,  and *

Output

For each testcase, print the infix equation, ended by a newline character

Sample Input  Download

Sample Output  Download

Tags




Discuss