#include<algorithm> #include<string.h> #include<iostream> #include<stdio.h> #include<string.h> using namespace std; struct Student { char no[100]; char name[100]; int age; char sex[5]; bool operator < (const Student &A) const //重载使得能够用sort函数进行排序 { return strcmp(no, A.no)<0; } }buf[1000]; int main() { int n; int m; while (scanf_s("%d", &n) != EOF) { for (int i = 0; i < n; i++) { std::cin >> buf[i].no >> buf[i].name >> buf[i].sex >> buf[i].age; } sort(buf, buf + n); std::cin >> m; while (m-- != 0) { int ans = -1; char x[30]; std::cin >> x; //待查找学号 int top = n - 1, base = 0; while (top >= base) { int mid = (top + base) / 2; int tmp = strcmp(buf[mid].no, x); if (tmp == 0) { ans = mid; break; } else if (tmp > 0) top = mid - 1; else base = mid + 1; } if (ans == -1) cout << "No answer" << endl; else printf("%s %s %s %d", buf[ans].no, buf[ans].name, buf[ans].sex, buf[ans].age); } } return 0; }