编译错误,c++上却可以

B2052 简单计算器

LANXIANGYU0329 @ 2023-11-18 14:19:47

#include<iostream>
using namespace std;
int main(){
    int a,b;
    char c;
    cin>>a>>b>>c;
    if(c=='+'){
        cout<<a+b;
    }else{
        cout<<"Invalid"<<" "<<"operator!";
    if(c=='-'){
        cout<<a-b;
    }else{
        cout<<cout<<"Invalid"<<" "<<"operator!";
    if(c=='*'){
        cout<<a*b;
    }else{
        cout<<"Invalid"<<" "<<"operator!";

    if(c=='/' && b==0){
        cout<<"Divided"<<" "<<"by"<<" "<<"zero!";
    }
    if(c=='/' && b!=0){
        cout<<a/b;
    }else{
        cout<<"Invalid"<<" "<<"operator!";
    }
    }
    }
    }
    return 0;
}

by Argvchs @ 2023-11-18 14:22:29

@LANXIANGYU0329 cout<<cout


by LANXIANGYU0329 @ 2023-11-18 14:24:24

@Argvchs 谢谢


by LANXIANGYU0329 @ 2023-11-18 14:35:10

@Argvchs 还是不可以AC


by FreedomKing @ 2023-11-18 14:48:44

@LANXIANGYU0329 这明显不对啊


by FreedomKing @ 2023-11-18 14:51:47

@LANXIANGYU0329 改了下,自己看代码。

#include<bits/stdc++.h>
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=='/' && b==0) cout<<"Divided"<<" "<<"by"<<" "<<"zero!";
                else{
                    if(c=='/' && b!=0) cout<<a/b;
                    else cout<<"Invalid"<<" "<<"operator!";
                }
            }
        }
    }
    return 0;
}

by FreedomKing @ 2023-11-18 14:53:03

@LANXIANGYU0329 你这马蜂真的丑得要死了,你连样例都不测完吗,样例二明显过不了好吗


by _aa_ @ 2023-12-05 19:49:12

@FreedomKing 《马蜂》,我是蒟蒻


|