文章

81

粉丝

2

获赞

521

访问

11.4k

头像
查找学生信息2 题解:
P1476 清华大学机试题
发布于2026年3月17日 21:20
阅读数 45

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

struct Student{
    string name;
    string gender;
    int age;
};

int main(){
    int n;
    cin >> n;

    map<string, Student> mp;

    for(int i = 0; i < n; i++){
        string id;
        Student s;

        cin >> id >> s.name >> s.gender >> s.age;
        mp[id] = s;
    }

    int m;
    cin >> m;

    for(int i = 0; i < m; i++){
        string id;
        cin >> id;

        if(mp.count(id)){ 
            cout << id << " "
                 << mp[id].name << " "
                 << mp[id].gender << " "
                 << mp[id].age << endl;
        }else{
            cout << "No Answer!" << endl;
        }
    }

    return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发