五十五.L1-005 考试座位号

在这里插入图片描述

#include<iostream>
#include<vector>
using namespace std;
struct stu
{
    
    
    string s;
    int one , two;
};
int main()
{
    
    
    int n, m, t;
    cin >> n;
    vector<stu> a(n);
    for(int i = 0; i<n; i++)
    {
    
    
        cin >> a[i].s >> a[i].one >> a[i].two;
    }
    cin >> m;
    for(int i = 0; i<m; i++)
    {
    
    
        cin >> t;
        for(int j = 0; j<n; j++)
        {
    
    
            if(a[j].one == t)
            {
    
    
                cout << a[j].s << " " << a[j].two << endl;
                break;
            }
        }
    }
    return 0;
}

在这里插入图片描述
定义一个结构类型变量用来存放参赛者的数据,再通过vector()函数动态存放输入的参赛者的数据。最后判断输入的试机号来找出对应的考试信息。

猜你喜欢

转载自blog.csdn.net/JiangYu200015/article/details/108671973