思路

哈希表存学生学号和信息的对应就 ok 了

#include<iostream>
#include<unordered_map>

using namespace std;

int main(){
    int n, m;
    while(cin >> n){
        unordered_map<string, string> students;
        for(int i = 0; i < n; i ++){
            string id, name, gender, age;
            cin >> id >> name >> gender >> age;
            students[id] = id + " " + name + " " + gender + " " + age;
        }
        cin >> m;
        string target;
        for(int i = 0; i < m; i ++){
            cin >> target;
            if (students.find(target) != students.end())
                cout << students[target] << endl;
            else cout << "No Answer!" << endl;
        }
    }
    return 0;
}