'commit'
This commit is contained in:
29
TangDou/XiTi/1034.cpp
Normal file
29
TangDou/XiTi/1034.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int num1, num2;
|
||||
char op;
|
||||
cin >> num1 >> num2 >> op;
|
||||
|
||||
switch (op) {
|
||||
case '+':
|
||||
cout << num1 + num2 << endl;
|
||||
break;
|
||||
case '-':
|
||||
cout << num1 - num2 << endl;
|
||||
break;
|
||||
case '*':
|
||||
cout << num1 * num2 << endl;
|
||||
break;
|
||||
case '/':
|
||||
if (num2 == 0) cout << "Divided by zero!" << endl;
|
||||
else cout << num1 / num2 << endl;
|
||||
break;
|
||||
default:
|
||||
cout << "Invalid operator!" << endl;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user