我是靠谱客的博主 炙热秀发,最近开发中收集的这篇文章主要介绍杭电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所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部