求助神犇!为什么这样会全错!谢谢!

P1579 哥德巴赫猜想(升级版)

Alextokc @ 2017-01-24 21:42:33

#include <iostream>
using namespace std;
bool jp(int n){
    if (n<=1) return false;
    for (int i=2;i*i<=n;++i){
        if (n%i==0) return false;
    }
    return true;
}
int main(){
    int n;
    cin>>n;
    for (int f=2;f<=n;++f){
        for (int s=f;s<=n;++s){
            if (jp(f)&&jp(s)&&jp(n-f-s)){
                cout<<f<<" "<<s<<" "<<n-f-s<<endl;
                break;
            }
        }
    }
    return 0;
}

by zhou1693742720 @ 2017-01-28 17:42:47

break 改成 return 0


by 野生小卒 @ 2017-03-18 22:54:36

@zhou1693742720

break只能退出一层循环,return可以退出整个程序


|