fork download
  1. #include <iostream>
  2. #include <stack>
  3. using namespace std;
  4.  
  5. int main() {
  6. stack <int> s;
  7.  
  8. s.push(12);s.push(32);s.push(123);s.push(76);s.push(442);s.push(243);s.push(123);
  9.  
  10. for (int i = 0; i < 7; i++) {
  11. cout << s.top() << "\n";
  12. s.pop();
  13. }
  14.  
  15. }
Success #stdin #stdout 0s 5312KB
stdin
5 1 2 3 4 5
stdout
123
243
442
76
123
32
12