题解 | #查找学生信息#
查找学生信息
https://www.nowcoder.com/practice/fe8bff0750c8448081759f3ee0d86bb4
#include <bits/stdc++.h> using namespace std; struct Student{ string num; string name; string sex; int age; }; int main() { int n; cin>>n; map<string,Student> M; for(int i=0;i<n;i++){ Student s; cin>>s.num>>s.name>>s.sex>>s.age; M[s.num]=s; } int m; cin>>m; string num; for(int i=0;i<m;i++){ cin>>num; if(M.find(num)!=M.end()){ //printf("%s %s %s %d",M[num].num,M[num].name,M[num].sex,M[num].age); cout<<M[num].num<<" "<<M[num].name<<" "<<M[num].sex<<" "<<M[num].age<<endl; } else{ cout<<"No Answer!"<<endl; } } } // 64 位输出请用 printf("%lld")