Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include<stack>
- #include<queue>
- #include<sstream>
- using namespace std;
- void the_helper(string &str){//минаваме елементите по референция без да запазваме резултата
- stack<char>s;//стека който ще приема данни
- for(auto it:str)s.push(it);//вкарваме данните в стека
- str.clear();//изчистваме текущите символи от стринга
- while(!s.empty())//връщаме данните в обратен ред
- {
- str.push_back(s.top());
- s.pop();
- }
- }
- int main()
- {
- string str;//стринга който ще обръщаме
- getline(cin, str);
- the_helper(str);//викаме си функцията която ще обръща стринга
- cout << str;//извеждаме обърнатия стринг
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement