题解 | #查找学生信息#
查找学生信息
https://www.nowcoder.com/practice/fe8bff0750c8448081759f3ee0d86bb4
#include <asm-generic/errno.h> #include <iostream> using namespace std; #define MAXSIZE 1000 struct Student{ string id, name; string sex; int age; }; int main() { int a,m; string check; Student stu[MAXSIZE]; while (cin >> a) { // 注意 while 处理多个 case for(int i=0; i<a; i++) cin>>stu[i].id>>stu[i].name>>stu[i].sex>>stu[i].age; cin>>m; for(int i=0; i<m; i++){ cin>>check; for(int i=0; i<a; i++){ if(check == stu[i].id){ cout<<stu[i].id<<" "<<stu[i].name<<" "<<stu[i].sex<<" "<<stu[i].age<<endl; break; } if(i==a-1) cout<<"No Answer!"<<endl; } } } } // 64 位输出请用 printf("%lld")