AcWing 726. 质数
1. 地址
https://www.acwing.com/problem/content/728/
2. 题解
// 此题跟完全数这道题差不多
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
int count;
int number;
int flag = 1;
scanf("%d",&count);
while(count--){
scanf("%d",&number);
for(int i=2;i<=sqrt(number);i++){
if(number % i == 0){
flag = 0;
break;
}
}
if(flag == 1){
printf("%d is prime\n",number);
}else{
printf("%d is not prime\n",number);
}
flag = 1;
}
return 0;
}
标签:count,int,质数,726,include,AcWing
From: https://www.cnblogs.com/gao79135/p/17367795.html