9 degrees OJ 1069 student information (simulation), oj1069

Source: Internet
Author: User

9 degrees OJ 1069 student information (simulation), oj1069

Question 1069: Find Student Information

Time Limit: 1 second

Memory limit: 32 MB

Special question: No

Submit: 7836

Solution: 2116

Description:

Enter information about N students and then query them.

Input:

The first Act N entered, that is, the number of students (N <= 1000)

The next N rows contain information about N students. The information format is as follows: 01 Li Jiangnan 2102 Liu Tang male 2303 Zhang Jun male 1904 Wang na female 19 then input a M (M <= 10000 ), next, there will be M rows, representing M queries. Each row will enter a student ID in the following format: 02030104
Output:

Output M rows. Each row contains the information of a student corresponding to the query.

If No student information exists, "No Answer!" Is output !"
Sample input:
401 Li Jiang male 2102 Liu Tang male 2303 Zhang Jun male 1904 Wang na female 1950203010403
Sample output:
02 Liu Tang male 2303 Zhang Jun male 1901 Li Jiang male 2104 Wang na female 1903 Zhang Jun male 19
#include<stdio.h>#include<string.h>typedef struct node{    char id[100];    char name[200];    char sex[10];    int age;}node;node data[1001];int main(int argc, char *argv[]){    int N;    int M;    while(~scanf("%d",&N))    {        for(int i=0;i<N;++i)        {            scanf("%s%s%s%d",data[i].id,data[i].name,data[i].sex,&data[i].age);        }        scanf("%d",&M);        char queryid[100];        int j;        for(int i=0;i<M;++i)        {            scanf("%s",queryid);            for(j=0;j<N;++j)            {                if(strcmp(data[j].id,queryid)==0)                {                    printf("%s %s %s %d\n",data[j].id,data[j].name,data[j].sex,data[j].age);                    break;                }            }            if(j==N)                printf("No Answer!\n");        }    }    return 0;}



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.