代码如下:
#include<iostream>
#include<iomanip>
using namespace std;
void main()
{
int T;
cin>>T;
char c;
int a,b;
for(int i=0;i<T;i++)
{
cin>>c>>a>>b;
switch(c)
{
case '+':
{
cout<<a+b<<endl;
break;
}
case '-':
{
cout<<a-b<<endl;
break;
}
case '*':
{
cout<<a*b<<endl;
break;
}
case '/':
{
if(a%b==0) cout<<a/b<<endl;
else cout<<fixed<<setprecision(2)<<(double)a/b<<endl;
break;
}
default:
{
cout<<"error"<<endl;
break;
}
}
}
}
加油!!!!!!!!!!!!!!!!!!