C++

#include<string>
using namespace std;
#define MAX 1000
class Student {
public:
	string id;//学号
	string name;
	string sex;//true男,false女
	int age;

	Student() {
		id = "-1";//代表该结点信息未录入
	}
};
Student s[MAX];
//查找id,返回结点角标,如果没找到,那么返回-1;
int find(string id) {
	for (int i = 0;i<=MAX; i++) {
		if (s[i].id == "-1")break;
		if (s[i].id == id)return i;
	}
	return -1;
}
int main() {
	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> s[i].id >> s[i].name >> s[i].sex >> s[i].age;
	}
	int M; cin >> M;
	for (int i = 0; i < M; i++) {
		string temp_id; cin >> temp_id;
		int pos = find(temp_id);
		if (pos == -1) {
			cout << "No Answer!" << endl;
		}
		else {
			cout << s[pos].id << " " << s[pos].name << " " << s[pos].sex << " " << s[pos].age << endl;
		}
	}

	return 0;
}