小编Den*_*mer的帖子

C++ LIFO 队列,从 FIFO 到 LIFO 的简单示例

我怎样才能把它变成一个 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)

c++ queue stack lifo

0
推荐指数
1
解决办法
8482
查看次数

标签 统计

c++ ×1

lifo ×1

queue ×1

stack ×1