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;}