#include <iostream>
using namespace std;
int main()
{
while(true)
{
try
{
int x;
scanf("%d",&x);
char c;
scanf("%c",&c);
int y;
scanf("%d",&y);
switch(c)
{
case '+':
cout<<x+y<<endl;
break;
case '-':
cout<<x-y<<endl;
break;
case '*':
cout<<x*y<<endl;
break;
case '/':
if(y==0) cout<<"除数不可以为0"<<endl;
else
cout<<x/y<<endl;
break;
default:
break;
}
}
catch(exception e)
{
cout<<"出错!"<<endl;
}
}
return 0;
}
通过编译
C++计算器代码
最新推荐文章于 2024-09-12 21:22:43 发布