题目传送门: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; }