题解 | #查找学生信息#

查找学生信息

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

#include <cstdio>
#include <iostream>
#include <map>
#include <string>
using namespace std;
map<string,string> student;
int main() {
    int n;
    while(cin>>n){
        student.clear();
        for(int i=0;i<n;i++){
            string num;
            cin>>num;
            getchar();
            string info;
            getline(cin, info);
            student[num]=info;
        }
        int m;
        cin>>m;
        for(int i=0;i<m;i++){
            string lookup;
            cin>>lookup;
            if(student[lookup]=="") cout<<"No Answer!"<<endl;
            else cout<<lookup<<" "<<student[lookup]<<endl;
        }

    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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