PAT Basic 1041 exam seat number (15 points)

PAT Each candidate will be assigned seat number two in the exam, the test machine is a seat, a seat is exam. Under normal circumstances, the first candidates in the admission test machine to obtain a seat number, the seating state into the test machine, the system displays the seat number of the candidate for an examination, the examination candidates need to change the test to take the seat. But some candidates late, test machine has ended, they can only receive the test machine took the seat numbers turn to you, find out their examination seat number from the background.

Input formats:

The first input line is given a positive integer  N ( ≤), followed by  N rows, each row gives the information for a candidate: 准考证号 试机座位号 考试座位号. Wherein 准考证号the 16-bit numbers, the seat from 1 to  N numbers. Enter the ticket number to ensure that everyone is different, and no time will two people assigned to the same seat.

After the candidate information, gives a positive integer  M ( ≤), then given row  M of the test machine to be queried seat number, separated by a space.

Output formats:

Each seat number corresponding to the test machine to be queried, in a row corresponding to the output candidates ticket number and seat number examination, separated by a space.

Sample input:

4
3310120150912233 2 4
3310120150912119 4 1
3310120150912126 1 3
3310120150912002 3 2
2
3 4

Sample output:

3310120150912002 2
3310120150912119 1


#include <iostream>
using namespace std;
struct stu{
    string stuNum;
    int a;
    int b;
};
int main(){
    int T,M,m;
    cin>>T;
    stu s[T];
    for(int i=0;i<T;i++){
        cin>>s[i].stuNum>>s[i].a>>s[i].b;
    }
    cin>>M;
    while(M--){
        cin>>m;
        for(int i=0;i<T;i++){
            if(s[i].a==m){
                cout<<s[i].stuNum<<" "<<s[i].b<<endl;
                break;
            }
        }
    }
    system("pause");
    return 0;
}

Find simple

 

Guess you like

Origin www.cnblogs.com/littlepage/p/11280190.html