题意
给定N
个学生的学号、试机号和考试号,询问多个试机号对应的学号和考试号。
思路
暴力查就好了。
代码
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
vector<tuple<string, int, int>> a(n);
for (int i = 0; i < n; ++i) {
string id;
int x, y;
cin >> id >> x >> y;
a[i] = tie(id, x, y);
}
int m;
for (cin >> m; m--;) {
int x;
cin >> x;
for (auto e : a) {
if (x == get<1>(e)) {
cout << get<0>(e) << ' ' << get<2>(e) << '\n';
}
}
}
return 0;
}
HINT
不定时更新更多题解,Basic Level 全部AC代码,详见 link ! ! !