Advertisement
amermo

TP T-4 Z3

Mar 24th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. void Razmijeni(char &a, char &b)
  5. {
  6.     char temp(a);
  7.     a = b;
  8.     b = temp;
  9. }
  10.  
  11. void IzvrniString(std::string &s)
  12. {
  13.     int i(0), j(s.length()-1);
  14.     while(i < j)
  15.     {
  16.         Razmijeni(s[i], s[j]);
  17.         i++;
  18.         j--;
  19.     }
  20. }
  21.  
  22. int main()
  23. {
  24.     std::string s{"Ovo je neki tekst..."};
  25.     IzvrniString(s);
  26.     std::cout << s;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement