Files
python/TangDou/LuoGuBook/P5736.cpp

24 lines
439 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N];
bool isPrime(int n) {
if (n < 2) return false;
for (int i = 2; i <= n / i; i++)
if (n % i == 0)return false;
return true;
}
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++)
if (isPrime(a[i]))
cout << a[i] << " ";
return 0;
}