其他分享
首页 > 其他分享> > 1041 考试座位号

1041 考试座位号

作者:互联网

题目传送门:https://pintia.cn/problem-sets/994805260223102976/problems/994805281567916032

题解:

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

struct Infor{
    string str;
    int num1;
    int num2;
};

void InitInfor(Infor infor[],int n){
    for(int i=0;i<n;i++){
        infor[i].str="";
        infor[i].num1=-1;
        infor[i].num2=-1;
    }
}

int main(){
    int n,M,temp;
    cin>>n;
    Infor infor[n];
    InitInfor(infor,n);
    for(int i=0;i<n;i++){
        cin>>infor[i].str>>infor[i].num1>>infor[i].num2;
    }
    cin>>M;
    while(M--){
        cin>>temp;
        for(int i=0;i<n;i++){
            if(temp==infor[i].num1) cout<<infor[i].str<<" "<<infor[i].num2<<endl;
        }
    }
    return 0;
}

 

标签:1041,infor,num1,num2,int,include,Infor,座位号,考试
来源: https://www.cnblogs.com/Gzu_zb/p/10497144.html