stack的常见接口
#include<iostream> #include<stack> using namespace std; //栈stack容器 void test01() { //特点符合先进后出的数据结构 stack<int> s; //入栈 s.push(10); s.push(20); s.push(30); s.push(40); //只要栈不为空,查看栈顶,并且执行出栈操作 while (!s.empty()) { //查看栈顶操作 cout << "栈顶元素为: " << s.top() << endl; //出栈 s.pop(); } cout << "栈的大小: " << s.size() << endl; } int main() { test01(); return 0; }
C++容器篇-----stack的使用方法
猜你喜欢
转载自blog.csdn.net/weixin_44820625/article/details/106494280
今日推荐
周排行