You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
439 B
24 lines
439 B
#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;
|
|
} |