P0008. Sums and substractions P36811


Statement
 

pdf   zip

thehtml

Your task is to write a program that evaluates a sequence of expressions. Each expression consists of sums, subtractions, changes of sign and redundant symbols ‘+’ among one or more natural numbers.

Input

The input is a sequence of lines. Each line contains a correct expression, consisting of sums, subtractions, changes of sign and redundant symbols ‘+’ among one or more natural numbers. Each line contains, at least, one number. The first number of each line can be preceded by one or more changes of sign and redundant symbols ‘+ ’. Each line ends with a dot and contains exclusively the characters ‘+’, ‘-’, ‘0’, …, ‘9’.

Output

For each line of the input, print a line with the result of its evaluation.

Observations

  • Read the input character by character, even the characters that form the numbers.
  • The final results as well as the intermediate calculations will always fit in a int.
Public test cases
  • Input

    42.
    --9.
    +9876.
    --+---23.
    2+3.
    2-4-3.
    ++1-20--3-+-++-+50.
    

    Output

    42
    9
    9876
    -23
    5
    -5
    -66
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++