给出整数 a,b,若 a≤b,输出 YE5,否则输出 N0

给出整数 a,b,若 a≤b,输出 YE5,否则输出 N0

#include 
using namespace std;
int main (){
    int a,b;
    cin >> a >>b;
    if(a<=b){
        cout << "YES"; 
    }
    else
    cout << "NO";
    return 0;
} 

各位看看是否有误?

少了一对花括号, 改成这样:

#include <iostream>
using namespace std;
int main (){
    int a,b;
    cin >> a >>b;
    if(a<=b){
        cout << "YES"; 
    } else {
    cout << "NO";
    return 0;
    }
} 
 

若有帮助, 点一个"采纳"不谢。

没错,不过还是建议else的{}加上

是对的,代码没问题。