Untitled
unknown
plain_text
10 months ago
985 B
2
Indexable
Never
#include <iostream> #include <stack> #include <cctype> class Stack { public: std::stack<char> loadstack(int upper); }; std::stack<char> Stack::loadstack(int upper) { std::stack<char> resultStack; if (upper == 1) { for (char c = 'Z'; c >= 'A'; --c) { resultStack.push(c); } } else { for (char c = 'z'; c >= 'a'; --c) { resultStack.push(c); } } return resultStack; } int main() { Stack stack; std::stack<char> lowercaseStack = stack.loadstack(0); std::stack<char> uppercaseStack = stack.loadstack(1); std::cout << "Lowercase Stack: "; while (!lowercaseStack.empty()) { std::cout << lowercaseStack.top() << " "; lowercaseStack.pop(); } std::cout << "\nUppercase Stack: "; while (!uppercaseStack.empty()) { std::cout << uppercaseStack.top() << " "; uppercaseStack.pop(); } return 0; }