我是靠谱客的博主 炙热秀发,这篇文章主要介绍杭电oj1170,现在分享给大家,希望可以做个参考。

根据输入的数学字符±*/计算数值
需要注意: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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部