Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- template <typename Tip>
- bool ImaLi(const Tip &z, const std::vector<Tip> v)
- {
- for (auto x: v) {
- if (x==z) return true;
- }
- return false;
- }
- template <typename Tip1>
- std::vector <Tip1> Presjek (std::vector<Tip1> v1, std::vector<Tip1> v2)
- {
- std::vector <Tip1> v3(0);
- for (auto x: v1)
- {
- if ((ImaLi(x,v2)==true) && (ImaLi(x,v3)==false))
- v3.push_back(x);
- }
- return v3;
- }
- int main () {
- std::vector <string> vek1{3,2,1,5,4,6,7,3};
- std::vector<string> vek2{3,5,3,6,7,4,2,8,9};
- std::cout<<"Presjek vektora: ";
- for (auto x: Presjek(vek1,vek2)) std::cout<<x<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement