麻烦大佬看一下哪错了,为啥单个数能判断正确,加上for循环就结果就错了

第一个for循环
int main()
{
int N, sum = 0, n, m;
int rest, sum2 = 0, s[1000], a = 2, b, flag;
cout << "请输入搜索范围:[最小值,最大值]:\n";
cin >> n;
cin >> m;
for (int N = n;N <= m;++N)
{
if (N % 12 == 0 || N % 18 == 0)
{
cout << N << "是盈数\n";
}
else
{
flag = 1;
vector factors;
find_factors(N, factors);
for (auto& it : factors)
sum = it + sum;
rest = sum - N;
if (rest > 0)
{
vector> powerSets;
find_power_sets(factors, powerSets);
for (vector& ps : powerSets)
{
for (int& i : ps)
sum2 = sum2 + i;
s[a] = sum2;
s[1] = 0;
b = s[a] - s[a - 1];
a++;
if (b == N)
{
cout << N << "是盈数" << endl;
}
else
{
flag = 0;
break;
}
cout << flag << endl;
cout << b << endl;
}
if (flag == 0)
cout << N << "是奇怪数" << endl;
}
else
cout << N << "是亏数" << endl;
}
}

cout << endl;
return 0;

}

c++
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问