0
点赞
收藏
分享

微信扫一扫

c++超级简单的计算器

践行数据分析 2022-05-01 阅读 75
c++

c上面的示例都太奇怪了,不是函数就是栈

#include<iostream>
using namespace std;
int main(){
	double a,b=0;//声明变量				
	char d;
	
	for(int q=1;q==q;q++){//永远执行 
	cin>>a>>d>>b;//输入表达式 
	if(d=='+'){						
		cout<<a<<"+"<<b<<"="<<a+b<<endl;//判断符号并输出结果 
	}
	if(d=='-')
	{
		cout<<a<<"-"<<b<<"="<<a-b<<endl;
	}
	if(d=='*')
	{		 
		cout<<a<<"*"<<b<<"="<<a*b<<endl;
	}
	if(d=='/')
	{	
		cout<<a<<"/"<<b<<"="<<a/b<<endl;				
	}
	}
}

这样就好多了~

举报

相关推荐

0 条评论