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

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;
int T,a,b,c,t;
char x,y;
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%d %c %d %c %d",&a,&x,&b,&y,&c);
		if((x=='+'||x=='-')&&(y=='*'||y=='/'||y=='%')){
			if(y=='*')	t=b*c;
			else if(y=='/')	t=b/c;
			else if(y=='%')	t=b%c;
			if(x=='+')	t=a+t;
			else if(x=='-')	t=a-t;
		}
		else{
			if(x=='+')	t=a+b;
			else if(x=='-')	t=a-b;
			else if(x=='*')	t=a*b;
			else if(x=='/')	t=a/b;
			else if(x=='%')	t=a%b;
			if(y=='+')	t+=c;
			else if(y=='-')	t-=c;
			else if(y=='*')	t*=c;
			else if(y=='/')	t/=c;
			else if(y=='%')	t%=c;
		}
		printf("%d\n",t);
	}
}