Răspuns :

#include<iostream>
using namespace std;
int main(){int i,j,n,a[100],b[100],k,x=0,y;
cin>>n;
for(i=1;i<=n;i++){cin>>a[i];}
for(i=1;i<=n;i++){y=a[i];k=0;for(j=1;j<=y;j++){if(y%j==0){k++;}}
if(k==2){x++;b[x]=y;}}
for(i=1;i<=x;i++){cout<<b[i]<<" ";}}