B1041. 考试座位号

 

基本思路

  • 两个类型的座位号,试机座位号为a,考试座位号为b,先得到a再得到b
  • 准考证号为id
  • 定义一个学生结构体,将a设为下标,b和id作为该结构体的属性
#include <bits/stdc++.h>
using namespace std;
struct Student{
    long long id;// 准考证号 
    int examSeat;// 考试座位号 
}testSeat[1010];// 试机座位号 
int main(int argc, char *argv[]) {
    int N, n, m, examSeat, t;
    long long id;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> id >> m >> examSeat;
        testSeat[m].id = id;
        testSeat[m].examSeat = examSeat;
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> t;
        cout << testSeat[t].id << ' ' << testSeat[t].examSeat << endl;        
    }
    return 0;    
}
原文地址:https://www.cnblogs.com/YC-L/p/12267450.html