WSTI

10d_3

Dec 22nd, 2011
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. /*
  8. Napisz funkcję, która dla zmiennej typu string zwraca łańcuch w odwrotnej kolejności znaków (odwraca łańcuch), zmienną należy przekazać przez referencję (funkcja typu void);
  9. wykorzystać funkcje z biblioteki STL; sprawdzić działanie funkcji;
  10. */
  11.  
  12. void odwroc(string &fuck)
  13. {
  14. int length = fuck.length();
  15.  
  16.         for (int i=0; i<(length/2); i++)
  17.         {
  18.             swap(fuck[i], fuck[length-1]);
  19.             length--;
  20.         }
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26.    
  27.     string shit = "1234567";
  28.     odwroc(shit);
  29.     cout << "odwrocone gowno to: " << shit << endl;
  30.    
  31.     getch();    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment