WA样例输入:
7
1 2 3 4 5 1 2
WA输出:
2 3 5 2
犇犇救一下QWQ
#include<iostream>
#include<cmath>
using namespace std;
bool primer(int num){
for(int step = 2;step < num;step++){
if(num < 2) return false;
if( num % step == 0)
return false;
}
return true;
}
int main(){
int n,pd,num,ss = 0;
cin>>n;
unsigned int arr[n];
for(int step = 0;step < n;step ++){
cin>>num;
pd = primer(num);
if(pd)
arr[ss++] = num;
}
for(int step = 0;step < ss ;step++){
cout<<arr[step]<<" ";
}
return 0;
}