Răspuns:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,nr;
while(true){
cout<<"N = ";cin>>n;
if(n>0 && n<=99)
break;
}
vector<int> x (0,n+1);
vector<int> y;
for(int i=0;i<n;i++){
cout<<"Numarul "<<i+1<<" : ";cin>>nr;
x.push_back(nr);
}
for(int z : x){
if(z%3==0)
y.push_back(z);
}
for(int z : y)
cout<<z<<" ";
return 0;
}
Explicație: