#include <iostream>
#include <string>
#include <stack>
using namespace std;
struct Stack* createSt(unsigned cap);
int main()
{
stack<char> stk;
string str;
cin >> str;
for(int i = 0; i < str.length(); i++)
stk.push(str.at(i));
string reverse;
while(!stk.empty())
{
reverse.push_back(stk.top());
stk.pop();
}
cout<<"Reversed string is "<<reverse<<endl;
return 0;
}
#include <string>
#include <stack>
using namespace std;
struct Stack* createSt(unsigned cap);
int main()
{
stack<char> stk;
string str;
cin >> str;
for(int i = 0; i < str.length(); i++)
stk.push(str.at(i));
string reverse;
while(!stk.empty())
{
reverse.push_back(stk.top());
stk.pop();
}
cout<<"Reversed string is "<<reverse<<endl;
return 0;
}
No comments:
Post a Comment