C++编程入门之十一(stack容器)
stack容器
1.1stack基本概念
入栈叫push,出栈叫pop
1.1stack常用接口
#include"pch.h"
#include<iostream>
#include<string>
#include<opencv2/opencv.hpp>
#include<vector>
#include<algorithm> // 标准算法头文件
#include<stack>
using namespace std;
using namespace cv;
//栈stack容器
void test01()
{
stack<int>s;
s.push(10);
s.push(20);
s.push(30);
s.push(40);
cout << "栈的大小:" << s.size() << endl;
while (!s.empty())
{
cout << "栈顶元素为:" << s.top() << endl;
s.pop();
}
cout << "栈的大小:" << s.size() << endl;
}
int main()
{
test01();
system("pause");
return 0;
}