簡單四則運算

#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;
 } 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章