1041 考试座位号 (15分)

- 小思路:建立string类型的二维数组stu[1005][2],假设试机座位号为t,将准考证号S1存在stu[t][0],考试座位号Stu[t][0]中,直接查询就好~
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
const int N = 1005;
string stu[N][5];
int n, m;
int main()
{
cin >> n;
int t;
string s1, s2;
for (int i = 0; i < n ; i ++ )
{
cin >> s1 >> t >> s2;
stu[t][0] = s1;
stu[t][1] = s2;
}
cin >> m;
for (int i = 0; i < m; i ++ )
{
cin >> t;
cout << stu[t][0] << " " << stu[t][1] << endl;
}
return 0;
}

浙公网安备 33010602011771号