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: 1756kB
Author: 2018212212028
In contest: 1290

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#include<set>
#define ll long long
using namespace std;
const int N = 1010;
const int inf = 0x3f3f3f3f;
#define PI 3.141592653589
#define fr(i,r,l) for(int i=r;i<l;i++)


int main() {

    int t;
    scanf("%d", &t);
    while (t--) {
		int a, b, c, ans;
		char d, e;
        scanf("%d %c %d %c %d", &a, &d, &b, &e, &c);
        if ((d == '+' || d == '-') && (e == '*' || e == '/' || e == '%')) {
            if (e == '*') {
                ans = b * c;
            } else if (e == '/') {
                ans = b / c;
            } else if (e == '%') {
                ans = b % c;
            }
            if (d == '+') {
                ans = a + ans;
            } else if (d == '-') {
                ans = a - ans;
            }
        } else {
            if (d == '+') {
                ans = a + b;
            } else if (d == '-') {
                ans = a - b;
            } else if (d == '*') {
                ans = a * b;
            } else if (d == '/') {
                ans = a / b;
            } else if (d == '%') {
                ans = a % b;
            }
            if (e == '+') {
                ans += c;
            } else if (e == '-') {
                ans -= c;
            } else if (e == '*') {
                ans *= c;
            } else if (e == '/') {
                ans /= c;
            } else if (e == '%') {
                ans %= c;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}