100 60 100 100 100 第一题 int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int n; cin >> n; cin.ignore(20, '\n'); string line; queue<int>temp; for (int j = 0; j < n; j++) { getline(cin, line); if (line.find("PUSH") != -1) { int num = stoi(line.substr(5, line.length())); temp.push(num); } else if (line.find("TOP") != -1) { if (temp.empty()) { cout << -1 << endl; } else { cout << temp.front() << endl; } } else if (line.find("POP") != -1) { if (temp.empty()) { cout << -1 << endl; } else { temp.pop(); } } else if (line.find("SIZE") != -1) { cout << temp.size() << endl; } else if (line.find("CLEAR") != -1) { while (!temp.empty()) { temp.pop(); } } } } return 0; }
点赞 10

相关推荐

起名字真难233:人家只有找猴子的预算,来个齐天大圣他们驾驭不住呀😂😂
点赞 评论 收藏
分享
剑桥断刀:找啥工作,牛客找个比如大厂软开或者随便啥的高薪牛马,大把没碰过妹子的技术仔,狠狠拿捏爆金币
点赞 评论 收藏
分享
牛客网
牛客企业服务