题目传送门

#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;
}

相关文章:

  • 2021-06-24
  • 2021-07-05
  • 2021-06-24
  • 2021-12-13
  • 2021-08-19
猜你喜欢
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案