Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- template<typename Tip1, typename Tip2>
- int BrojZajednickih(Tip1 pocetak1, Tip1 iza_kraja1, Tip2 pocetak2, Tip2 iza_kraja2)
- {
- int br(0);
- Tip1 pom(pocetak1);
- while(pocetak1!=iza_kraja1)
- {
- while(pom<pocetak1)
- {
- if(*pocetak1==*pom++)
- continue;
- else
- {
- Tip2 pom2(pocetak2);
- while(pom2!=iza_kraja2)
- {
- if(*pocetak1==*pom2++)
- {
- br++;
- break;
- }
- }
- }
- }
- pocetak1++;
- }
- return br;
- }
- int main()
- {
- std::cout<<"Unesi broj elemenata 1.bloka: ";
- int n;
- std::cin>>n;
- std::cout<<"Unesi elemenate 1.bloka: ";
- std::vector<int> v(n);
- for(int i=0; i<n; i++)
- std::cin>>v[i];
- std::cout<<"Unesi broj elemenata 2.bloka: ";
- int m;
- std::cin>>m;
- std::cout<<"Unesi elemenate 2.bloka: ";
- std::vector<int> w(m);
- for(int i=0; i<m; i++)
- std::cin>>w[i];
- std::cout<<BrojZajednickih(std::begin(v), std::end(v), std::begin(w), std::end(w));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement