C++stack容器stack 常用接口
功能描述:栈容器常用的对外接口
#include <iostream>
#include <stack>
using namespace std
;
void test()
{
stack
<int> s
;
s
.push(10);
s
.push(20);
s
.push(30);
while (!s
.empty())
{
cout
<< "栈顶元素为: " << s
.top() << endl
;
s
.pop();
}
cout
<< "栈的大小为: " << s
.size() << endl
;
}
int main()
{
test();
return 0;
}
C++stack容器stack 常用接口
转载请注明原文地址:https://tech.qufami.com/read-27625.html