题解 | #查找学生信息#
查找学生信息
https://www.nowcoder.com/practice/fe8bff0750c8448081759f3ee0d86bb4
#include<iostream> using namespace std; const int N = 1100; struct Student{ string id; string name; string gender; int age; }s[N]; int main(void) { int n; cin >> n; for(int i = 0;i < n;i++) { cin >> s[i].id >> s[i].name >> s[i].gender >> s[i].age; } int m; cin >> m; for(int i = 0;i < m;i++) { string idd; cin >> idd; bool f = false; for(int j = 0;j < n;j++) { if(idd == s[j].id){ f = true; printf("%s %s %s %d\n",s[j].id.c_str(),s[j].name.c_str(),s[j].gender.c_str(),s[j].age); break; } } if(!f) cout << "No Answer!"<<endl; } return 0; }