酷代码 AI
菜单
服务商

C++实现:快速查询学生考试座位号,解决签到表查找难题!

```cpp #include <iostream> #include <string> #include <unordered_map> int main() { int n; std::cin >> n; std::unordered_map<std::string, int> studentSeat; for (int i = 1; i <= n; ++i) { std::string studentId; std::cin >> studentId; studentSeat[studentId] = i; } int m; std::cin >> m; for (int i = 0; i < m; ++i) { std::string studentId; std::cin >> studentId; if (studentSeat.find(studentId)!= studentSeat.end()) { std::cout << studentSeat[studentId] << std::endl; } else { std::cout << "na" << std::endl; } } return 0; } ``` ######[AI写代码神器 | 224点数解答 | 2024-10-18 23:41:07]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]