补全9月11日至13日课评:为13名学生创建请假文档,为5个班级创建总结文档
This commit is contained in:
33
C++代码/学习/未命名5.cpp
Normal file
33
C++代码/学习/未命名5.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define endl '\n'
|
||||
using namespace std;
|
||||
|
||||
int n;
|
||||
int arr[100100];
|
||||
|
||||
// 判断一个数是不是质数
|
||||
|
||||
int main(){
|
||||
int num;
|
||||
cin >> num;
|
||||
|
||||
bool ok = true; // 一开始我认为这个数是质数
|
||||
|
||||
// 质数(素数):除了1和它本身
|
||||
for(int i = 2; i <= sqrt(num); i++){
|
||||
// 让i 作为除数
|
||||
if(num % i == 0){
|
||||
// i把num整除了
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(ok){
|
||||
cout << "是质数";
|
||||
} else {
|
||||
cout << "不是质数";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user