Quick actions

cmd+k|ctrl+k

Navigation

Languages

List of Stacks implementation

Snippet info

Language

Cpp

Visibility

public

Author

ha7shu

Created

2025-01-25T14:10:10.731599Z

Updated

2025-01-25T14:12:23.506403Z

#include <bits/stdc++.h>
using namespace std;

int main() {
    list<stack<int>> listOfStacks;

    stack<int> stack1;
    stack1.push(10);
    stack1.push(20);
    stack1.push(30);

    stack<int> stack2;
    stack2.push(40);
    stack2.push(50);

    listOfStacks.push_back(stack1);
    listOfStacks.push_back(stack2);

    for (auto& st : listOfStacks) {
        stack<int> temp = st;
        while (!temp.empty()) {
            cout << temp.top() << " ";
            temp.pop();
        }
        cout << endl;
    }

    return 0;
}
INFO