Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- void swap( std::string &str, int index1, int index2 )
- {
- char x = str[index1];
- str[index1] = str[index2];
- str[index2] = x;
- }
- std::string zmienione_metoda_z_polecenia( std::string str )
- {
- for(auto i = 0; i < str.length() / 2; i++)
- swap( str, i, ( str.length() - 1 - i ) );
- return str;
- }
- std::string reverse( std::string str )
- {
- std::reverse( str.begin(), str.end() );
- return str;
- }
- int main()
- {
- std::string str = "programowanie";
- std::cout << reverse( str ) << "\n";
- std::cout << zmienione_metoda_z_polecenia( str ) << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement