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

相关推荐

那一天的Java_J...:看工资定规模,钱多就叫大厂
点赞 评论 收藏
分享
驼瑞驰_招募评论官版...:一共经历几次握手?
点赞 评论 收藏
分享
09-15 18:37
已编辑
门头沟学院 后端工程师
让校招回归公平好吗。各大公司学习一下
秋招路在何方:互娱和雷火的笔试是确实是我见过最严格的,支持
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务