c++温故而知新
作者:互联网
que遍历
#include<iostream>
#include<queue>
using namespace std;
int main(int argc, char* argv[]) {
queue<int> myqueue;
myqueue.push(1);
myqueue.push(2);
myqueue.push(3);
int myqueue_size = myqueue.size();
for(int i = 0; i < myqueue_size; i++) { //myqueue_size 必须是固定值
cout << myqueue.front() << endl;
myqueue.push(myqueue.front());
myqueue.pop();
}
}
int main(int argc, char** argv) {
// priority_queue<int> que;
queue<int> que;
que.push(2);
que.push(4);
que.push(5);
while (!que.empty()){
cout<<que.front()<<endl;
que.pop();
}
return 0;
}
标签:温故而知新,int,c++,queue,push,que,myqueue,size 来源: https://blog.csdn.net/weixin_44811068/article/details/113625971