- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int num1 = 0;
- int num2 = 0;
- char temp; // 字串string char
- cout<<"請輸入第一個數字: "<<endl;
- cin>>num1;
- cout<<"請輸入+ - * / : "<<endl;
- cin>>temp;
- cout<<"請輸入第二個數字: "<<endl;
- cin>>num2;
-
- switch(temp) //switch判斷 (參數)
- {
- case '+': // '字串'
- cout << num1 << " + " << num2 << " = " << num1+num2 << endl;
- break;
- case '-': // '字串'
- ???
- break;
- case '*': // '字串'
- ???
- break;
- case '/': // '字串'
- ???
- break;
-
- default: // 預設值
- cout<<"輸入錯誤!"<<endl;
- }
- system("pause");
- return 0;
- }
複製代碼 |