问题及代码
/*
*作者:李长鸿
*问题输入:1+2形式的式子
*问题输出:结果
*/
#include <cstdio>
#include<iostream>
using namespace std;
int main()
{
int a=100;
int b=20;
int c;
char oper;
cin>>a>>oper>>b;
switch(oper)
{
case '+':c=a+b;break;
case '-':c=a-b;break;
case '*':c=a*b;break;
default :if(b==0)c=a;
else c=a/b;break;
}
cout<<"c="<<c<<endl;
return 0;
}