首页 > 学院 > 开发设计 > 正文

PAT 1007 素数对猜想

2019-11-08 18:31:45
字体:
来源:转载
供稿:网友
#include<stdio.h>#include<math.h>int main(){ int n; int i,j; int flag=1; int temp=2; int count=0; scanf("%d",&n); for(i=3;i<=n;i++){ for(j=2;j<=sqrt(i);j++){ if(i%j==0){ flag=0; break; } } if(flag){ if(i-temp==2){ count++; temp=i; } else{ temp=i; } } flag=1; } PRintf("%d/n",count); return 0;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表