#include <iostream>
#include <stack>
using namespace std;
int main()
{
cout << "STL stack exercise" << endl << endl;
stack<int> MyStack;
cout << "init without anything" << endl;
cout <<"MyStack.size(): " << MyStack.size() << endl << endl;
cout << "push something in" << endl;
MyStack.push(1);
MyStack.push(2);
MyStack.push(3);
MyStack.push(4);
cout <<"MyStack.size(): " << MyStack.size() << endl << endl;
cout << "pop all out" << endl;
while (!MyStack.empty())
{
cout << MyStack.top() << endl;
MyStack.pop();
}
cout << endl << endl;
return 0;
}
No comments:
Post a Comment