首页 > 腾讯第一题为啥我是0%。。
头像
Taiye
发布于 2020-04-26 23:10
+ 关注

腾讯第一题为啥我是0%。。

我佛了,腾讯开发岗第一题我到底错在哪。。求大佬指教下本彩笔。。自测题目给的用例能过,一提交就0%。。
#include<iostream>
#include<queue>
using namespace std;

int main() {

    queue<int> q;
    int N;
    cin >> N;
    while (N--)
    {
        int n;
        cin >> n;
        while (n--)
        {
            string s;
            cin >> s;
            if (s == "PUSH") {
                int a;
                cin >> a;
                q.push(a);
                continue;
            }
            if (s == "TOP") {
                if (q.empty()) {
                    cout << -1 << endl;
                }
                else {
                    cout<<q.front()<<endl;
                }
                continue;
            }
            if (s == "POP") {
                if (q.empty()) {
                    cout << -1 << endl;
                }
                else {
                    q.pop();
                }
                continue;
            }
            if (s == "SIZE") {
                cout << q.size() << endl;
                continue;
            }
            if (s == "CLEAR") {
                queue<int> temp;
                swap(temp, q);
            }
            if (n == 0) {
                queue<int> temp;
                swap(temp, q);
            }
        }
    }

}



全部评论

(3) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐