@root 为什么只有90分???

12121 Game for peace 2024-05-26 14:36:47 21
#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 == '/'){
        if (b != 0) cout << a / b;
    }
    else{
        cout << "Invalid operator!";
    }
    return 0;
}
{{ vote && vote.total.up }}

共 1 条回复

root 站长
    else if (c == '/'){
        if (b != 0) cout << a / b;
        //这里 b 等于 0 要输出语句 Divided by zero!
    }