#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
struct stu
{
string idcard;
int shijihao;
int kaoshihao;
}st[1001];
int main()
{
int num;
cin >> num;
string n1;
int n2;
int n3;
for (int i = 0; i < num; i++)
{
cin >> n1 >> n2 >> n3;
st[n2].idcard = n1;
st[n2].kaoshihao = n3;
}
int chazhaonum;
cin >> chazhaonum;
int chazhao;
for (int r = 0; r < chazhaonum; r++)
{
cin >> chazhao;
cout << st[chazhao].idcard << " " << st[chazhao].kaoshihao << endl;
}
return 0;
}
这题具有巧妙之处是:
st[n2].idcard = n1;
st[n2].kaoshihao = n3;
从而输出直接st[chazhao].idcard << " " << st[chazhao].kaoshihao