根据输入的数学字符±*/计算数值
需要注意: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("%.2lfn",A/B);
//刚开始就是这样错的,输出了0.00
printf("%.2lfn",A/(double)B);
else
cout<<A/B<<endl;
}
}
return 0;
}
最后
以上就是炙热秀发最近收集整理的关于杭电oj1170的全部内容,更多相关杭电oj1170内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复