杭电1170

来源:互联网 发布:佰迪欧百信渔具淘宝店 编辑:程序博客网 时间:2024/06/06 02:35

WA 了好多遍。。。小细节要注意的嘛~

#include<iostream>

#include<iomanip>
using namespace std;
int main()
{
int i,t, a,b;
while(cin>>t)
{char ch;
for(i=1;i<=t;i++)
{
cin>>ch;
cin>>a>>b;
if(ch=='+') cout<<a+b<<endl;
if(ch=='-') cout<<a-b<<endl;
if(ch=='*') cout<<a*b<<endl;
if(ch=='/') 
{
if(a%b==0) cout<<a/b<<endl;
else cout<<fixed<<setprecision(2)<<1.0*a/b<<endl;
}
}
}
}
原创粉丝点击