您的位置:首页 > 其它

51nod-1106质数检测

2016-09-12 11:20 211 查看
正常判断检测。

#include <iostream>
#include <stdio.h>
using namespace std;
int  judge(int n)
{
for(int i=2;i*i<=n;i++)
{
if(n%i==0)
{
return 0;
}
}
return 1;
}
int main()
{
int n,t;
cin>>n;
while(n--)
{
cin>>t;
if(judge(t))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: