STL之stack(栈)

栈(statck)这种数据结构在计算机中是相当出名的。栈中的数据是先进后出的(First In Last Out, FILO)。栈只有一个出口,允许新增元素(只能在栈顶上增加)、移出元素(只能移出栈顶元素)、取得栈顶元素等操作。 在STL中栈一共就5个常用操作函数(top()、push()、pop()、 size()、empty())
#include
#include
#include
using namespace std ;
typedef stack Q ;
int main()  {
    Q q ;
    for(int i = 0 ; i < 10 ; i++)
        q.push(i) ;
    while(!q.empty())   {
        cout << q.top() << " " ;
        q.pop() ;
    }
    cout << endl ;
    return 0 ;
}
原文地址:https://www.cnblogs.com/NYNU-ACM/p/4236860.html