第十周项目1

来源:互联网 发布:域名dns更改 编辑:程序博客网 时间:2024/05/01 09:49
/* *Copyright (c) 2014,烟台大学计算机学院 *All rights reserved. *文件名称:Annpion.cpp *作者:苏强 *完成日期:2014年10月30日 *版本号:v1.0 * *问题描述:输入“1+2”形式的式子,并输出相应的结果*输入描述:“1+2” *程序输出: 3*/#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