您的位置:首页 > 编程语言 > Python开发

ZOJ Problem Set - 3782 python

2018-03-26 18:45 323 查看
Ternary CalculationTime Limit: 2 Seconds      Memory Limit: 65536 KBComplete the ternary calculation.

Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:There is a string in the form of "number1 operatora number2 operatorb number3". Each operator will be one of {'+', '-' , '*', '/', '%'}, and each number will be an integer in [1, 1000].

Output

For each test case, output the answer.

Sample Input

5
1 + 2 * 3
1 - 8 / 3
1 + 2 - 3
7 * 8 / 5
5 - 8 % 3

Sample Output

7
-1
0
11
3P=T = input()
list = []
while T:
T-=1

n = raw_input()
list.append(eval(n))
for i in range(P):
print(list[i])

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  acm python