1 条题解

  • 1
    @ 2024-8-4 8:40:57

    我又来啦!

    #include<iostream>
    using namespace std;
    
    int main(){
        int a,b;
        string c;
        cin>>a>>b>>c;
        if(c=="+"){
           cout<<a+b;
           return 0;
        }
        if(c=="-"){
            cout<<a-b;
            return 0;
        }
        if(c=="*"){
            cout<<a*b;
            return 0;
        }
        if(c=="/"){
            if(b==0){
                cout<<"Divided by zero!";
                return 0;
            }
            if(b!=0){
                cout<<a/b;
                return 0;
            } 
        }
        else{
            cout<<"Invalid operator!";
            return 0;
        }
    }
    

    留言:那些没过的人会不会不知道”+-*/“的数据类型是什么吧。

    • 1

    信息

    ID
    45
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    递交数
    62
    已通过
    22
    上传者