题解 | 学生查询

学生查询

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

#include <iostream>
#include <string>
using namespace std;

typedef struct {
    int id;
    string name;
    string gender;
    int age;
} Student;

int main() {
    int m, n;
    cin >> m;
    while (m--) {
        cin >> n;
        Student stu[n];
        for (int i = 0; i < n; i++) {
            cin >> stu[i].id >> stu[i].name >> stu[i].gender >> stu[i].age;
        }
        int t;
        cin >> t;
        for (int i = 0; i < n; i++) {
            if (t == stu[i].id) {
                cout << stu[i].id << " " << stu[i].name << " " << stu[i].gender << " " <<
                     stu[i].age << endl;
            }
        }
    }
}

全部评论

相关推荐

千千倩倩:简历问题有点多,加v细聊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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