题解 | #查找学生信息#|全部用字符串存储就行了

查找学生信息

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

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

int main() {
    //用map map<string,vector<string>>
    int n;map<string,vector<string>>m;
    while(cin>>n){
        while(n-->0){
        string s1,s2,s3, s4;
        cin>>s1>>s2>>s3>>s4;
        vector<string> t;t.push_back(s2);
        t.push_back(s3);t.push_back(s4);
        m[s1]=t;
        }
        cin>>n;
        while(n-->0){//开始输出
        string s;cin>>s;
        if(m.find(s)!=m.end())
        cout<<s<<" "<<m[s][0]<<" "<<m[s][1]<<" "<<m[s][2]<<" "<<endl;
        else
        cout<<"No Answer!"<<endl;
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

07-23 14:04
东北大学 C++
既然这样,为什么不点击就送呢
牛马88号:因为你合适。但有很多笔试就挂了、通过了再排序的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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