1041 考试座位号 (15 分)

题目链接:1041 考试座位号 (15 分)

 

这道题目比较简单,建立一个结构体即可。

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 
 4 struct student
 5 {
 6     char s[15];
 7     int tryid;
 8     int testid;
 9 }a;
10 
11 vector<student> input;
12 
13 int main()
14 {
15     int n;
16     cin>>n;
17     for(int i=0;i<n;i++)
18     {
19         scanf("%s %d %d",a.s,&a.tryid,&a.testid);
20         input.push_back(a);
21     }
22     int m,temp;
23     cin>>m;
24     for(int i=0;i<m;i++)
25     {
26         scanf("%d",&temp);
27         for(int j=0;j<input.size();j++)
28         {
29             if(input[j].tryid==temp)
30                 printf("%s %d\n",input[j].s,input[j].testid);
31         }
32     }
33     return 0;
34 }

 

posted @ 2019-01-20 22:20  focusDing  阅读(436)  评论(0编辑  收藏  举报