#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<int>mstack;
for (int i = 0; i < 5; i++)
mstack.push(i);//进栈
cout << "size:" << mstack.size() << endl;//栈的大小
while (!mstack.empty())//判断栈是否为空
{
cout << " " << mstack.top();返回栈顶元素
mstack.pop();出栈
}
cout << endl;
}
C++ STL stack(栈)
最新推荐文章于 2024-06-28 20:40:18 发布