cout stack in c 2b 2b

Solutions on MaxInterview for cout stack in c 2b 2b by the best coders in the world

showing results for - "cout stack in c 2b 2b"
Alice
12 Apr 2016
1#include <iostream>
2#include <stack>
3#include <string>
4
5int main(int argc, const char *argv[])
6{
7    std::stack<int> stack;
8    stack.push(1); 
9    stack.push(3); 
10    stack.push(7); 
11    stack.push(19); 
12
13    for (std::stack<int> dump = stack; !dump.empty(); dump.pop())
14        std::cout << dump.top() << '\n';
15
16    std::cout << "(" << stack.size() << " elements)\n";
17
18    return 0;
19}
20