1041. Exam seat number (15)

1041. Exam seat number (15)

time limit
400 ms
memory limit
65536 kB
code length limit
8000 B
Judgment procedure
Standard
author
CHEN, Yue

Each PAT candidate will be assigned two seat numbers when taking the test, one for the test machine and one for the test. Under normal circumstances, candidates first get the seat number of the test machine when they enter the venue. After entering the test machine state, the system will display the test seat number of the test taker. During the test, the test taker needs to change to the test seat to sit. However, some candidates are late and the test machine has ended. They can only ask you for help with the test machine seat number they received, and find out their test seat number from the background.

Input format:

Enter the first line to give a positive integer N (<=1000), followed by N lines, each line gives a candidate's information: "admission ticket number test machine seat number test seat number". The admission ticket number consists of 14 digits, and the seats are numbered from 1 to N. Entering ensures that everyone's admission ticket number is different and that no two people are assigned to the same seat at any time.

After the candidate information, a positive integer M (<=N) is given, and the M number of seats to be queried are given in the next line, separated by spaces.

Output format:

Corresponding to each test machine seat number that needs to be queried, output the corresponding test taker's admission ticket number and test seat number in one line, separated by a space.

Input sample:
4
10120150912233 2 4
10120150912119 4 1
10120150912126 1 3
10120150912002 3 2
2
3 4
Sample output:
10120150912002 2
10120150912119 1

In order to save time, you can analyze the meaning of the title, find the relevant subscript (the seat number of the body seat, you can directly assign the value to the array with the seat number), and then use it as the subscript of the array


#include<stdio.h>
struct node{
    char zhun[14];
    int zuo;
    int kao;
}st[1001];
int main(){
    int n,m,s1,s2;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s %d %d",st[i].zhun,&st[i].zuo,&st[i].kao);
    }
    int search[1001];
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%d",&search[i]);
        for(int j=0;j<n;j++){
            if(search[i]==st[j].zuo){
                printf("%s %d\n",st[j].zhun,st[j].kao);
            }
        }
    }
    return 0;
}


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324417538&siteId=291194637