题解 | #判断一个数是不是质数#
判断一个数是不是质数
https://www.nowcoder.com/practice/b8bb5e7703da4a83ac7754c0f3d45a82
#include <bits/stdc++.h>
using namespace std;
int main() {
int x;
cin>>x;
for(int i=2;i*i<=x;i++){
if(x%i==0){
cout<<"不是质数";
return 0;
}
}
cout<<"是质数";
return 0;
}
这其实更应该用来练习return 0。

查看5道真题和解析
