清华大学机试 查找学生信息 Easy

基本思想:

无;

关键点:

无;

#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;

const int maxn = 2000;

struct node {
    string name;
    string sex;
    int grade;
};


node ls[maxn];

int main() {
    int n,m;
    while (cin >> n) {
        map<string, node>mp;
        int d;
        string a,b, c;
        for (int i = 0; i < n; i++) {
            cin >> a >> b >> c >> d;
            node no;
            no.sex = c;
            no.name = b;
            no.grade = d;
            mp[a] = no;
        }
        cin >> m;
        for (int i = 0; i < m; i++) {
            cin >> a;
            if (mp.find(a) != mp.end()) {
                cout << a << " " << mp[a].name << " " << mp[a].sex << " " << mp[a].grade << endl;
            }
            else {
                cout<<"No Answer!" << endl;
            }
        }
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/songlinxuan/p/12422668.html