c++请问这段代码出了什么问题?

我的代码:判断整除

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    if(n%m) cout<<"YES";
    else cout<<"NO";
    return 0;
}

n%m改成n%m==0即可

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
if(!(n%m)) cout<<"YES";
else cout<<"NO";
return 0;
}
这样改以下就行

是这样的,n%m 你输入n和m,大部分情况下都不会正好满足整除。比如你输入的是15 2,显然15%2!=0的,但其会返回1,因此条件变成了if(1),所以不会满足,一直都是no。