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

相关推荐

不愿透露姓名的神秘牛友
07-01 17:13
想去,但是听说加班强度实在难崩,所以拒绝了,现在有点心梗对面hr感觉也是实习生,打电话的时候怪紧张的,但是感觉人很好嘞
水中水之下水道的鼠鼠:哥们这不先去体验一下,不行再跑呗,大不了混个实习经历(有更好的转正offer就当我没说)
点赞 评论 收藏
分享
05-05 21:45
已编辑
广州大学 Java
点赞 评论 收藏
分享
想按时下班的我在等o...:我投测试也是这个情况,不知道咋办了
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-27 20:55
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务