第十周项目一 输入1+2形式的式子

来源:互联网 发布:json 遍历map 编辑:程序博客网 时间:2024/05/16 14:29
 
问题及代码
/**作者:李长鸿*问题输入: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;}

0 0
原创粉丝点击