stack.cpp

来自「Vc.Net入门与提高源码」· C++ 代码 · 共 24 行

CPP
24
字号
#include <stack>
#include <iostream>
int main( )
{
   using namespace std;
   stack <int> s1, s2;
   s1.push( 10 );
   s1.push( 20 );
   s1.push( 30 );
   stack <int>::size_type i;
   i = s1.size( );
   cout << "The stack length is " << i << "." << endl;
   i = s1.top( );
   cout << "The element at the top of the stack is "
        << i << "." << endl;
   s1.pop( );
   i = s1.size( );
   cout << "After a pop, the stack length is " 
        << i << "." << endl;
   i = s1.top( );
   cout << "After a pop, the element at the top of the stack is "
        << i << "." << endl;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?