#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main()//素性测试
{
int a, b, d, c;
a = 1;
while (a!=0)//当你输入0时,循环停止。
{
c = 0;
cout << "请输入您要测试的素数" << endl;
cin >> a;
for (int i = 1; i <= a; i++)
{
b = a%i;
if (b == 0)
{
c += 1;
}
d = c;
if (c>2)
{
cout << "不是素数" << endl;
break;
}
}
if (d == 2)
{
cout << "是素数" << endl;
}
system("pause");
system("cls");
}
system("pause");
return 0;
}