Start: Jun, 30, 2019 09:00:00
2019年度暑期短学期第十天 助教场
End: Jul, 08, 2019 23:59:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 4ms
Memory: 2020kB
Author: 2018212212094
In contest: 1290

#include<bits/stdc++.h>
using namespace std;
bool jud1(char a) {
	if (a == '+' || a == '-')return true;
	return false;
}
bool jud2(char a) {
	if (a == '*' || a == '/' || a == '%')return true;
	return false;
}
int main() {
	int n;
	cin >> n;
	getchar();
	while (n--) {
		int a, b, c, sum = 0;
		char x, y;
		scanf("%d ", &a);
		scanf("%c ", &x);
		scanf("%d ", &b);
		scanf("%c ", &y);
		scanf("%d", &c);
		if (jud1(x)) {
			if (jud2(y)) {
				if (y == '*')sum = b * c;
				else if (y == '/')sum = b / c;
				else if (y == '%')sum = b % c;
				if (x == '+')sum += a;
				else if (x == '-')sum = a - sum;
			}
			else {
				if (x == '+')sum = a + b;
				else if (x == '-')sum = a - b;
				if (y == '+')sum = sum + c;
				else if (y == '-')sum = sum - c;
			}
		}
		else {
			if (x == '*')sum = a * b;
			else if (x == '%')sum = a % b;
			else if (x == '/')sum = a / b;
			if (y == '+')sum = sum + c;
			else if (y == '-')sum = sum - c;
			else if (y == '*')sum = sum * c;
			else if (y == '/')sum = sum / c;
			else if (y == '%')sum = sum % c;
		}
		cout << sum << "\n";
	}
	return 0;
}