Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- template <typename IterTip1>
- IterTip1 RazmjeniBlokove(IterTip1 pocetak1, IterTip1 kraj1, IterTip1 pocetak2)
- {
- while(pocetak1 < kraj1)
- std::swap(*pocetak1++, *pocetak2++);
- return pocetak2;
- }
- int main()
- {
- int niz1[5]{1, 1, 1, 1, 1}, niz2[5]{2, 2, 2, 2, 2};
- RazmjeniBlokove(niz1+2, niz1+5, niz2);
- for(auto &x : niz1)
- std::cout << x << " ";
- std::cout << std::endl;
- for(auto &x : niz2)
- std::cout << x << " ";
- std::cout << std::endl;
- std::string s1{"testiramo izmjena"}, s2{"ttttttt"};
- RazmjeniBlokove(s1.begin()+1, s1.end()-10, s2.begin());
- std::cout << s1 << std::endl << s2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement