STL-queue 队列

 1 #include <iostream>
 2 #include <queue>
 3 
 4 using namespace std;
 5 
 6 int main()
 7 {
 8     // queue也很简单
 9     // push,pop,size,front
10     queue<int> q1;
11     q1.push(1);
12     q1.push(3);
13     q1.push(5);
14     cout<<q1.size()<<endl;
15     cout<<q1.front()<<endl;
16     // 不能访问队尾
17     //cout<<q1.tail()<<endl;
18     // 不反悔删除元素
19     //cout<<q1.pop()<<endl;
20     q1.pop();
21     cout<<q1.front()<<endl;
22     cout<<q1.size()<<endl;
23     return 0;
24 }

猜你喜欢

转载自www.cnblogs.com/jishuren/p/12238908.html
今日推荐