http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3782
题意:把输入的三元运算用计算机运算出来。
1 #include <bits/stdc++.h>
2 using namespace std;
3 int main() {
4 int t;
5 cin>>t;
6 while(t--) {
7 int a,b,c;
8 int s1=;
9 char n,m;
cin>>a>>n>>b>>m>>c;
if(n=='*'||n=='/'||n=='%') {
if(n=='*')
s1=a*b;
else if(n=='/')
s1=a/b;
else
s1=a%b;
if(m=='*')
s1=s1*c;
else if(m=='/')
s1=s1/c;
else if(m=='%')
s1=(int)s1%c;
else if(m=='+')
s1=s1+c;
else if(m=='-')
s1=s1-c;
} else if(m=='*'||m=='/'||m=='%') {
if(m=='*')
s1=b*c;
else if(m=='/')
s1=b/c;
else if(m=='%')
s1=b%c;
if(n=='+')
s1=a+s1;
else if(n=='-')
s1=a-s1;
} else {
if(n=='+')
s1=a+b;
else if(n=='-')
s1=a-b;
if(m=='+')
s1=s1+c;
else if(m=='-')
s1=s1-c;
}
printf("%d\n",s1);
}
return ;
}