Lập Trình C/C++ - Stack

#Code:
#include<iostream>
#include<stack>
using namespace std;

int main()
{
 /* Create a stack */
 stack data;

 /* Push data into the stack */
 data.push(10);
 data.push(20);
 data.push(30);
 data.push(40);
 
 cout << "Stack size: " << data.size() << endl;
 cout << "Data on top of the stack: " << data.top() << endl;

 /* Pop data from the stack */
 data.pop();

 cout << "Stack size after pop: " << data.size() << endl;
 cout << "Now top data on stack: " << data.top() << endl;
 
 return 0;
}

0 Comment:

Đăng nhận xét

Thank you for your comments!