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 i=0; i<b.size()-1; i++)
- std::cout<< b[i] << ",";
- std:: cout<<b[b.size()-1];
- std::cout<<std::endl;
- for(int i=0; i<c.size()-1; i++)
- std::cout<< c[i] << ",";
- std:: cout<<c[c.size()-1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement