#include <iostream>
#include<stack>
#include<string.h>
using namespace std;
int main()
{
char str[10]="abcdefgh";
stack<char> s;
for(int i=0;i<strlen(str);i++)
{
s.push(str[i]);
}
cout<<"reversed string ";
while(!s.empty())
{
cout<<s.top();
s.pop();
}
return 0;
}
#include<stack>
#include<string.h>
using namespace std;
int main()
{
char str[10]="abcdefgh";
stack<char> s;
for(int i=0;i<strlen(str);i++)
{
s.push(str[i]);
}
cout<<"reversed string ";
while(!s.empty())
{
cout<<s.top();
s.pop();
}
return 0;
}
No comments:
Post a Comment