我怎样才能把它变成一个 LIFO-> 后进先出队列?有什么简单的方法可以做到吗?这是一个 FIFO-> 先进先出队列。
using namespace std;
int main(){
queue<string> q;
cout << "Pushing one two three four\n";
q.push("one");
q.push("two");
q.push("three");
q.push("four");
cout << "Now, retrieve those values in FIFO order.\n";
while(!q.empty()) {
cout << "Popping ";
cout << q.front() << "\n";
q.pop();
}
cout << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)