#include<vector>
#include<iostream>
#include<string>
#include<stack>
using namespace std;
int main()
{
stack<int> s;
s.push(1); // void push(T t);壓棧存入數據
s.push(2);
s.push(3);
int result = s.top(); // T top();只輸出第一個頂部數據,不彈棧
int result2 = s.top();//result= result2
s.pop(); // void pop();彈棧存入數據
int result3 = s.top();
cout << s.empty() << endl;
int sz = s.size();
cout << result << " " << result2 << " " << result3 << endl;
}
stack棧的用法
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.