题解 | 查找学生信息

查找学生信息

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

#include <bits/stdc++.h>
using namespace std;

map<string,string> students;

int main() {
    int n;
    cin>>n;
    getchar();
    for(int i=0;i<n;i++){
        string str;
        getline(cin,str);
        int pos = str.find(" ");
        string id = str.substr(0,pos);
        students[id]=str;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        string a;
        cin>>a;
        if(students[a]=="") cout<<"No Answer!"<<endl;
        else cout<<students[a]<<endl;
    }
    return 0;
}

全部评论

相关推荐

递归到脑子变傻:杭州还有上位机用VB的,实在没绷住
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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