C++简单的计算器程序设计

来源:百度知道 编辑:UC知道 时间:2024/06/15 10:48:39
用switch语句实现一个能够进行+、-、×、÷运算的计算器。要求在除运算时要对除数进行判断,如果除数为0给出错误提示。

我也不是很懂,随便写的,没运行过,不知道有错误不
int sum()
{int a,b;
cout<"Please input first number:"
cin>>a;
Please input second number:"
cin>>b:
return a+b;}
int minus()
{int a,b;
cout<"Please input first number:"
cin>>a;
Please input second number:"
cin>>b;
if(b=0)return faulse;
else
return a\b;}
}
cou<<"input your choose,1 for +;1 for 除:"
int i;
cin>>i;
switch()
{case 1: sum();break;
case 2: minus();break:}