Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- bool prost (int n)
- {
- for (int i=2;i<n;i++)
- {
- if (n%i==0)return false;
- }
- return true;
- }
- int main()
- {
- std::cout<<"Unesite broj elemenata: ";
- int n;
- std::cin>>n;
- std::vector<int>a(n);
- for (int i=0;i<n;i++)
- std::cin>>a[i];
- std::vector<int>b,c;
- for (int x: a)
- {
- if(x==1) continue;
- else if (prost(x))
- b.push_back(x);
- else
- c.push_back(x);
- }
- for (int x: b)
- std::cout<<x<<" ";
- std::cout<<std::endl;
- for (int x:c)
- std::cout<<x<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement