Advertisement
naskedvi

T5 - zad.2.

Mar 30th, 2014
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include<algorithm>
  3. #include <string>
  4.  
  5. template <typename IterTip1, typename IterTip2>
  6. IterTip2 RazmjeniBlokove(IterTip1 pocetak, IterTip1 kraj, IterTip2 odrediste)
  7. {
  8. while(pocetak!=kraj)
  9. {
  10. auto pomocna(*pocetak);
  11. *pocetak++=*odrediste;
  12. *odrediste++=pomocna;
  13. }
  14. return odrediste;
  15. }
  16.  
  17. int main()
  18. {
  19. int niz1[12]{1,5,4,7,8,5,6,2,1,8,9,3};
  20. int niz2[5]{1,2,1,2,1};
  21.  
  22. RazmjeniBlokove(&niz1[2], &niz1[6], &niz2[1]);
  23. for(int i=0; i<12; i++)
  24. std::cout<<niz1[i]<<" ";
  25.  
  26. std::string a("Danas je lijep dan...");
  27. std::string b("suncan dan...");
  28.  
  29. RazmjeniBlokove(a.begin()+6, a.begin()+15, b.begin());
  30.  
  31. std::cout<<std::endl<<a;
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement