L1-005. Exam seat number, l1-005 exam seat number

Source: Internet
Author: User

L1-005. Exam seat number, l1-005 exam seat number

Each PAT candidate is assigned two seat numbers when taking the test. One is the test seat and the other is the test seat. Under normal circumstances, the examinee receives the test seat number before admission. After the seat enters the test status, the system displays the test seat number of the examinee. During the test, the examinee needs to change to the test seat number. However, some candidates are late and the trial has ended. They can only seek help from you with the phone number they receive and find their exam seat number from the background.

Input Format:

Enter the first line to give a positive integer N (<= 1000), and then N rows, each line to give a candidate's information: "Admission Ticket number test seat number ". The admission ticket number consists of 14 digits and the seat number ranges from 1 to N. Make sure that each person's admission ticket number is different, and no two people are assigned to the same seat at any time.

After the examinee information, a positive integer M (<= N) is given, and M test seat numbers to be queried are given in the next line, separated by spaces.

Output Format:

For each exam seat number to be queried, the admission ticket number and exam seat number of the corresponding examinee are output in one row, separated by one space.

Input example:

410120150912233 2 410120150912119 4 110120150912126 1 310120150912002 3 223 4

Output example:

10120150912002 210120150912119 1

Time Limit: 200 ms memory limit: 65536 kB code length limit: 8000 B Judgment program Standard author Chen Yue disconnects the idea: defines a structure to store the admission ticket number, seat number, and test number of the student, then a dual loop is created to query the seat number based on the input test number.
#include <stdio.h>#include <stdlib.h>typedef struct student{    char arr[15];    int x;    int y;}STU;int main(){    int n;    int i, j;    int m;    STU stu[1000];    int sel[1000] = {0};    scanf("%d", &n);    for(i = 0; i < n; i++)    {        scanf("%s", stu[i].arr);        scanf("%d", &stu[i].x);        scanf("%d", &stu[i].y);    }    scanf("%d", &m);    for(i = 0; i < m; i++)    {        scanf("%d", &sel[i]);    }    for(i = 0; i < m; i++)    {        for(j = 0; j < n; j++)        {            if(sel[i] == stu[j].x)            {                printf("%s %d\n", stu[j].arr, stu[j].y);            }        }    }    return 0;}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.