标签:
判断素数
# include <iostream>
# include <cmath>
using namespace std;
bool Isprimer(int n)
{
int sqr = sqrt(n * 1.0);
for(int i = 2; i <= sqr; i++)
{
if(n % i == 0)
return false;
}
return true;
}
int main()
{
int n;
while(cin >> n)
{
if(Isprimer(n))
cout << "Yes" << endl;
else
cout << "No" << endl;
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/lyf-acm/p/5452100.html