5、stack容器

stack<int>stk;

stk.push(elem)

stk.pop()

stk.top()

stk.empty()

stk.size()

#include<iostream>
using namespace std;
#include<stack>


void test01()
{
	stack<int>stk;

	stk.push(10);
	stk.push(20);
	stk.push(30);
	stk.push(40);
	stk.push(50);

	cout << "栈的大小:" << stk.size() << endl;

	while (!stk.empty())
	{
		cout << stk.top() << " ";
		stk.pop();
	}
	cout << endl;

	cout << "全部出栈后,栈的大小:" << stk.size() << endl;
}

int main()
{
	test01();

	system("pause");
	return 0;
}
上一篇:uc/OS系统移植


下一篇:P3680 [CERC2016]凸轮廓线 Convex Contour 题解