#include<iostream>
using namespace std;
int main(){
int a,b;
char c;
cin >> a >> b >> c;
if (c == '+'){
cout << a + b;
}
else if (c == '-'){
cout << a - b;
}
else if (c == '*'){
cout << a * b;
}
else if (c == '/'){
cout << a / b;
}
else{
cout << "Invalid operator!";
}
return 0;
}
共 2 条回复
谢谢!
乘法的除数不能为 0,所以这个地方要先判断除数是否为 0