#include<iostream>
using namespace std;
int main() {
int a,b;
cout << "请随机输入1个数";
cin >> a;
for (b = 2; b <= a; b++)
{
if (a%b == 0)
break;
}
if (a == b)cout << "该数是素数" << endl;
else cout << "该数不是素数" << endl;
return 0;
}
#include<iostream>
using namespace std;
int main() {
int a,b;
cout << "请随机输入1个数";
cin >> a;
for (b = 2; b <= a; b++)
{
if (a%b == 0)
break;
}
if (a == b)cout << "该数是素数" << endl;
else cout << "该数不是素数" << endl;
return 0;
}