题解 | #查找学生信息#

查找学生信息

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")

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 12:20
点赞 评论 收藏
分享
那一天的Java_J...:他本来公司就是做这个的,不就是正常的游戏客户端和服务器开发,软硬件联动,有啥恶心不恶心的,提前告诉你就是怕你接受不了,接受不了就没必要再往后走流程浪费时间,虽然这公司是一坨。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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