65,210
社区成员
发帖
与我相关
我的任务
分享
#include <queue>
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int main()
{
queue<int> q;
for (int i = 0; i < 5; i++){
q.push(i);
cout<< q.back() << endl;
}
cout <<"The size is "<< q.size() << endl;
for (int i = 0; i < 5; i++){
cout <<"head "<< q.front();
q.pop();
cout << " tail " << q.back() << endl;
}
cout<<"******"<<endl;
if(q.empty())
cout<<"Empty"<<endl;
q.pop();
cout << "tail "<< q.back() << endl;
system("pause");
/*
根据运行结果,队列q的队尾仍然是4
但是q的长度却为0,而且q不存在队首元素
*/
}

[/quote]

谢谢,我用的MinGW😂😂😂,不太懂编译器这块


