简单四则运算

#include<iostream>
using namespace std;

int main()
{
    int a,b;
    cout<<"================"<<endl;
    cout<<"整数四则运算:"<<endl;
     cout<<"请输入两个数字:";
     cin>>a>>b;
     cout<<"请输入要进行的运算(+,-,*,/):";
     char s;
     cin>>s;
     switch(s){
        case '+':
            cout<<a<<"+"<<b<<"="<<a+b<<endl;
             break;
             case'-':
             cout<<a<<"-"<<b<<"="<<a-b<<endl;
             break;
             case'*':
             cout<<a<<"*"<<b<<"="<<a*b<<endl;
             break;
             case'/':
             cout<<a<<"/"<<b<<"="<<a/b<<endl;
             break;
             default:
             cout<<"error"<<endl;
             break;  } 
             return 0;
 } 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章