#include <iostream> #include <algorithm> #include "cstring" #include "map" #include "unordered_map" using namespace std; typedef struct stu { string name; string sex; int age; } stu; unordered_map<string, stu> M; // 用散列表 int n,m; int main() { cin >> n; while (n--) { string id,name,sex; int age; cin >>id >> name >>sex >>age; stu student; student.name=name; student.sex=sex; student.age=age; M[id] = student; } cin >>m; while(m--){ string search; cin >> search; if(M.count(search) == 0){ cout << "No Answer!" << endl; }else { stu lll= M[search]; cout <<search<<' '<<lll.name<<' '<<lll.sex<< ' '<<lll.age<<endl; } } } // 64 位输出请用 printf("%lld")
用 哈希表 存