求问

问一下,为什么循环里i和j从一开始不正确呢?

 #include<iostream>
using namespace std;
int  main(){
    int n;
    cin>>n;
    for(int i=2;i<n;i++){
        for(int j=2;j<n;j++){
            if(i+j==n){
                if(i%2==0&&j%2==0)cout<<"YES, you can divide the watermelon into two even parts."<<endl;
                return 0;
            }
           
        }
    }
    cout<<"NO, you can't divide the watermelon into two even parts."<<endl;
}

}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务