-->
当前位置:首页 > 题库

PROGRAMMING:Simple formula

Luz5年前 (2021-05-10)题库579
###Task description
There is a formula in the form of a + B or A-B, which requires you to program to read in the formula and output its result.
Among the 2050 freshmen, student x is the best in C linguistics. He says that if can easily solve this problem, but teacher y does not allow him to use if and switch. Classmate x is worried and doesn't know what to do.
Can you solve this problem without using if and switch statements?
###Input format:
Give an expression in a row, such as a + B or a-b. A and B are integers. There may be several spaces before and after the operator.
###Output format:
Output the result of the formula in one line. If the formula is not addition or subtraction, output: error!.
###Input sample 1:
```in
1 + 2
```
###Output sample 1:
```out
three
```
###Input sample 2:
```in
1- 2
```
###Output sample 2:
```out
-1
```
###Input sample 3:
```in
1#2
```
###Output sample 3:
```out
error!
```






answer:If there is no answer, please comment