C++——stack和queue

1.简介

栈和队列的定义和之前的容器有所差别

2.简单地使用

void test_stack1()
{
	stack<int> st;
	st.push(1);
	st.push(2);
	st.push(3);
	st.push(4);

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

}

void test_queue1()
{
	queue<int> q;
	q.push(1);
	q.push(2);
	q.push(3);
	q.push(4);

	while (!q.empty())
	{
		cout << q.front() << " ";
		q.pop();
	}
	cout << endl;
}

3.练习题

1.232. 用栈实现队列 - 力扣(LeetCode)

2.155. 最小栈 - 力扣(LeetCode)

3.栈的压入、弹出序列_牛客题霸_牛客网 (nowcoder.com)

4.102. 二叉树的层序遍历 - 力扣(LeetCode)

5.150. 逆波兰表达式求值 - 力扣(LeetCode)

运算符的优先级顺序是由相邻两个运算符的优先级决定的

后缀表达式没有括号,括号是加强优先级的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值