1 Star 0 Fork 1

hanjun/Aha-Algorithms-practise

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2.1队列.cpp 590 Bytes
一键复制 编辑 原始数据 按行查看 历史
柳婼 提交于 2016-02-08 22:22 . rename
#include <iostream>
using namespace std;
struct queue {
    int data[1000000];
    int head;
    int tail;
};
int main() {
    queue q;
    q.head = 1;
    q.tail = 1;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> q.data[i];
        q.tail++;
    }
    while (q.head < q.tail) {
        cout << q.data[q.head] << " ";
        q.head++;
         
        q.data[q.tail] = q.data[q.head];
        q.tail++;
        q.head++;
    }
    return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/digua_ge/Aha-Algorithms-practise.git
git@gitee.com:digua_ge/Aha-Algorithms-practise.git
digua_ge
Aha-Algorithms-practise
Aha-Algorithms-practise
master

搜索帮助