题解 | 查找学生信息

查找学生信息

https://www.nowcoder.com/practice/fe8bff0750c8448081759f3ee0d86bb4

#include <iostream>
#include <map>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M;
    while(cin >> N){
        map<string, string> m;
        string ID, name, gender, age;
        for(int i = 0; i < N; i++){
            string ID, name, gender, age;
            cin >> ID >> name >> gender >> age;
            string s = ID + " " + name + " " + gender + " " + age;
            m[ID] = s;
        }
        cin >> M;
        for(int i = 0; i < M; i++){
            string x;
            cin >> x;
            if(m.count(x)) cout << m[x] << "\n";
            else cout << "No Answer!" << "\n";
        }
    }
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务