STL-stack栈

 1 #include <iostream>
 2 #include <stack>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     // 栈比较简单
 9     // push,pop,size,top
10     // 基本操作很少,很容易实现和使用
11     // 一般可以写数组模拟栈
12     stack<int> s1;
13     s1.push(2);
14     s1.push(4);
15 
16     cout<<s1.size()<<endl;
17     cout<<s1.top()<<endl;
18     s1.pop();
19     cout<<s1.top()<<endl;
20 
21     return 0;
22 }

猜你喜欢

转载自www.cnblogs.com/jishuren/p/12238894.html