#include<iostream>
#include <stack>
#include <list>
usingnamespace std;
int main()
{
stack<int, list<int> > stck;
//push the even values 2-10 onto the stack
stck.push(2);
stck.push(4);
stck.push(6);
stck.push(8);
stck.push(10);
//display the value at the top of the stack
cout<<"List Elements: ";
for(stck = list.begin(); stck != list.end(); stck++)
cout<<*stck<<" ";
//pop two values off of the stack
stck.pop();
stck.pop();
//display the new top of the stack
cout<<"List Elements: ";
for(stck = list.begin(); stck != list.end(); stck++)
cout<<*stck<<" ";
return 0;
}
My problem seems to be in displaying my stack. Can anyone help me with my loop?
Any help and criticism will be welcomed and appreciated, thank you!
Thank you sir.
You have helped me plenty today. It honestly seems simple in retrospect, but like I said, this is one of the final sections of the semester and is not included in the book, just through vague powerpoints.