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: 2018212212174
In contest: 1290

#include <bits/stdc++.h>
using namespace std;
int a, b, c, tot;
char d, e;
int main() 
{
    int t;
    scanf("%d", &t) ;
    while (t --) 
    {
        scanf("%d %c %d %c %d", &a, &d, &b, &e, &c) ;
        if ((d == '+' || d == '-') && (e == '*' || e == '/' || e == '%')) 
		{
            if (e == '*') 
			{
                tot = b * c ;
            } 
			else if (e == '/') 
			{
                tot = b / c ;
            } 
			else if (e == '%') 
			{
                tot = b % c ;
            }
            if (d == '+') 
			{
                tot = a + tot ;
            } 
			else if (d == '-') 
			{
                tot = a - tot ;
            }
        } 
		else 
		{
            if (d == '+') 
			{
                tot = a + b ;
            } 
			else if (d == '-') 
			{
                tot = a - b ;
            } 
			else if (d == '*') 
			{
                tot = a * b ;
            } 
			else if (d == '/') 
			{
                tot = a / b ;
            } 
			else if (d == '%') 
			{
                tot = a % b ;
            }
            if (e == '+') 
			{
                tot += c ;
            } 
			else if (e == '-') 
			{
                tot -= c ;
            } 
			else if (e == '*') 
			{
                tot *= c ;
            } 
			else if (e == '/') 
			{
                tot /= c ;
            } 
			else if (e == '%') 
			{
                tot %= c ;
            }
        }
        printf("%d\n", tot) ;
    }
    return 0;
}