Stack

#include <iostream>
#include <stack>
using namespace std;
int main()
{
    stack <int> i;
    i.push(10);
    i.push(20);
    i.push(30);
    i.push(40);
    do
    {
            cout<<i.top()<<endl;
            i.pop();
    }while(!i.empty());
    system("pause");
    return 0;
}

This is the output:
40
30
20
10

0 comments:

Post a Comment