Advertisement
sellmmaahh

TP-tut5-zad2

Sep 3rd, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. template <typename TipPok>
  7. TipPok swap_ranges_ (TipPok p1, TipPok p2, TipPok p3) {
  8.     while (p1!=p2) {
  9.         swap(*p1, *p3);
  10.         p1++;
  11.         p3++;
  12.     }
  13.     return p3;
  14. }
  15.  
  16. int main () {
  17.     int niz1[6]={1,2,3,4,5,6};
  18.     int niz2[6];
  19.     swap_ranges_(niz1,niz1+6,niz2);
  20.     for (int i=0; i<6; i++) cout<<niz2[i]<<" ";
  21.      cout<<endl;
  22.  
  23.     string s1="Selma je bila ovdje.";
  24.     string s2="Mali programercic  .";
  25.     swap_ranges_(s1.begin(), s1.end(), s2.begin());
  26.     cout<<s2;
  27.  
  28.  
  29.  
  30.  
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement