酷代码 AI
菜单
服务商
DeepSeek字节豆包讯飞星火
更多选项

C++初学者实现:根据学号快速查找考试座位号

```cpp #include <iostream> #include <string> #include <vector> using namespace std; int main() { int n; cin >> n; vector<string> studentIds(n); vector<int> seatNumbers(n); for (int i = 0; i < n; i++) { cin >> studentIds[i]; seatNumbers[i] = i + 1; } int m; cin >> m; for (int i = 0; i < m; i++) { string queryId; cin >> queryId; bool found = false; for (int j = 0; j < n; j++) { if (studentIds[j] == queryId) { cout << seatNumbers[j] << endl; found = true; break; } } if (!found) { cout << "na" << endl; } } return 0; } ``` ######[AI写代码神器 | 234点数解答 | 2024-10-18 23:45:37]

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