题解 | #查找组成一个偶数最接近的两个素数#

查找组成一个偶数最接近的两个素数

http://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9

你们的代码怎么这么长鸭

#include<stdio.h>
int fac(int a){
    for(int i=2;i<=a/2;i++)
        if(a%i==0)
            return 0;
    return 1;
}
int main(){
     int n;
    while(~scanf("%d",&n)){
        int max=2,i=2,another=n-i;
        while(i<=another){
            if(fac(i)&&fac(another))max=i;
            i++;
            another--;
        }
        printf("%d\n%d\n",max,n-max);
    }
}
全部评论
很6啊
点赞 回复 分享
发布于 2022-11-11 11:59 上海

相关推荐

11-11 16:40
已编辑
门头沟学院 人工智能
不知道怎么取名字_:这个有点不合理了,相当于已经毕业了,但还是没转正,这不就是白嫖
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务