- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstd_stack.cpp
More file actions
Latest commit
32 lines (24 loc) · 551 Bytes
/
Copy pathstd_stack.cpp
File metadata and controls
32 lines (24 loc) · 551 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Program to reverse a string
// Example: Input: "JoySaha" -- Output: "ahaSyoJ"
#include<iostream>
#include<stack>
static std::stack<char> stack;
intmain() {
std::string name = "aabbaaa";
std::string result;
for (int i = 0; i < name.length(); i++) {
stack.push(name[i]);
}
while (!stack.empty()) {
result.push_back(stack.top());
stack.pop();
}
std::cout << result << "\n";
if (name == result) {
std::cout << "It is a palindrome string!\n";
}
else {
std::cout << "It is not a palindrome string!\n";
}
std::cin.get();
}