#include <iostream>#include <string>using namespace std;int main(){ int a,b; char c; cout<<"輸入兩個數a,b"<<endl; cin>>a>>b; cin>>c; switch(c) { 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 "/": if (b==0) cout<<"除數不能為零!"<<endl; else cout<<a<<"/"<<b<<"="<<a/b<<endl; break; } return 0;}
#include <iostream>#include <string>using namespace std;int main(){ int a,b; char c; cout<<"輸入兩個數a,b"<<endl; cin>>a>>b; cin>>c; switch(c) { 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 "/": if (b==0) cout<<"除數不能為零!"<<endl; else cout<<a<<"/"<<b<<"="<<a/b<<endl; break; } return 0;}