素数判定 - 哈尔滨工业大学 题解:
#include<stdio.h>
#include<math.h>
using namespace std;
int fun(int x)
{
for(int i=2;i<=sqrt(x);i++)
{
if(x%i==0)
{
return 0;
}
}
return 1;
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
if(n<2)
{
printf("no\n");
continue;
}
if(fun(n))
{
printf(&qu...
登录后发布评论
暂无评论,来抢沙发