#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
请按任意键继续. . .