c++ 如何实现计算器功能
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int x,y;
char k;
cin>>x>>y>>k;
switch(k){
case '+':
cout<<x+y;
break;
case '-':
cout<<x-y;
break;
case '*':
cout<<x*y;
break;
case '/':
if(y==0) { cout<<"除数不能为零!!!";
break;
}
cout<<x/y;break;
default :
cout<<"错误!!!";}
return 0;
}