根据输入的数学字符±*/计算数值
需要注意:The result should be rounded to 2 decimal places If and only if it is not an integer.!!!!!
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
int T;
int A,B;
char C;
cin>>T;
while(T--){
cin>>C>>A>>B;
switch(C){
case '+':
cout<<A+B<<endl;
break;
case '-':
cout<<A-B<<endl;
break;
case '*':
cout<<A*B<<endl;
break;
}
if(C=='/'){
if(A%B!=0)
//printf("%.2lf\n",A/B);
//刚开始就是这样错的,输出了0.00
printf("%.2lf\n",A/(double)B);
else
cout<<A/B<<endl;
}
}
return 0;
}