Monday, 5 December 2016

Built in Stack

#include <iostream>
#include <stack>

using namespace std;

int main ()
{
    stack <string> tcr; /* Simple enough to create a stack */
    tcr.push("HT"); /* push() will add a value, think of queues */
    tcr.push("RBH");  /* adding some tcr to the deck */
    tcr.push("KMH");
    tcr.push("SM");
    cout << "There are " << tcr.size ();

    cout << " tcr in SEU, CSE" << endl;
    cout << "The tcr on the top of the is " ;

    cout << tcr.top() << endl;
    tcr.pop();
    cout << "The top tcr is now " << tcr.top() << endl;
    cout << tcr.size();


}

No comments:

Post a Comment