代码练习
#include <iostream>
using namespace std;
int n, x;
bool isPrime(const int x) {
for (int i = 2; i * i <= x; ++i)
if (x % i == 0) return false;
return true;
}
int main(void) {
scanf("%d", &n);
while (n--) {
scanf("%d", &x);
if (isPrime(x)) printf("%d is prime\n", x);
else printf("%d is not prime\n", x);
}
return 0;
}