c++初试-特殊容器(12)

#include <iostream>
#include<stack>
#include<queue>
#include<string>
#include<bitset>


using namespace std;

void test_stack();
void test_queue();
void test_priority_queue();
void test_bitset();
int main() {

	test_stack();
	cout << "----------------------------" << endl;
	test_queue();
	cout << "----------------------------" << endl;
	test_priority_queue();
	system("pause");
	return 0;
}

void test_bitset(){
	

}
void test_priority_queue(){
	priority_queue<float> pq;
	pq.push(1.1f);
	pq.push(3.1f);
	pq.push(32.1f);
	pq.push(4.1f);
	while(!pq.empty()){
		cout << pq.top() << endl;
		pq.pop();
	}

}
void test_queue(){
	queue<string> q;

	q.push("aaaaaaaa");
	q.push("bbbbbbbb");

	q.push("cccccccc");
	q.push("dddddddd");



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


}
void test_stack(){
	stack<int> st;

	st.push(1);
	st.push(2);
	st.push(3);
	st.push(4);

	cout << st.top() << endl;
	st.pop();
	cout << st.top() << endl;
	st.pop();


	st.top() =77;

	st.push(11);
	st.push(22);

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

4
3
22  a
11  a
77  a
1  a
----------------------------
aaaaaaaa
bbbbbbbb
cccccccc
dddddddd
----------------------------
32.1
4.1
3.1
1.1
请按任意键继续. . .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值