队列 <queue>

STL:

队列中pop完成的不是取出最顶端的元素,而是取出最低端的元素.也就是说最初放入的元素能够最先被取出(这种行为被叫做FIFO:First In First Out,即先进先出).

queue:front 是用来访问最底端数据的函数.

 1 #include <queue>
 2 #include <cstdio>
 3 uisng namespace std;
 4 
 5 int main()
 6 {
 7     queue<int> que;  //  声明存储int类型数据的队列
 8     que.push(1);     //  {}--{1}
 9     que.push(2);     //  {1}--{1,2}
10     que.push(3);     //  {1,2}--{1,2,3}
11     printf("%d
",que.front());  // 1
12     que.pop();       //  从队列移除{1,2,3}--{2,3}
13     printf("%d
",que.frout());  // 2
14     que.pop();       //  {2,3}--{3}
15     printf("%d
",que.frout());  // 3
16     que.pop();       //  {3}--{}
17     return 0;
18 }

<<挑战程序设计竞赛>>读后感

原文地址:https://www.cnblogs.com/wangmengmeng/p/5222671.html