不是哥们,这输出提示没空格啊
2024-09-17 17:02:01
发布于:云南
1阅读
0回复
0点赞
吐槽一下:
Goldbach's conjecture is wrong.
题目里写成了Goldbach′sconjectureiswrong.
正文开始:
#include<bits/stdc++.h>
using namespace std;
bool check(int x){
if(x < 2) return false;
for(int i = 2;i <= x / 2;i++){
if(x % i == 0) return false;
}
return true;
}
int f(int n){
for(int i = 3;i <= n / 2;i += 2){
if(check(i) && check(n - i)) return i;
}
}
int main(){
int n;
while(cin >> n){
if(n == 0) exit(0);
if(n < 6 || n % 2 == 1) cout << "Goldbach's conjecture is wrong.\n";
else cout << n << " = " << f(n) << " + " << n - f(n) << "\n";
}
}
这里空空如也
有帮助,赞一个