Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main ()
- {
- int v[1000],n,i,eprim,d,k;
- cout<<"n=";cin>>n;
- for (i=0;i<n;i++)
- {
- cout<<"v["<<i<<"]=";
- cin>>v[i];
- }
- cout<<"vector initial:"<<endl;
- for (i=0;i<n;i++)
- cout<<v[i]<<' ';
- cout<<endl;
- for (i=0;i<n;i++)
- {
- eprim=1;
- for (d=2;d<=sqrt(v[i]);d++)
- if (v[i]%d==0)
- eprim=0;
- if (eprim) {
- for (k=i;k<n-1;k++)
- v[k]=v[k+1];
- n--;--i;
- }
- }
- cout<<"vectorul final: "<<endl;
- for (i=0;i<n;i++)
- cout<<v[i]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement