1. 程式人生 > >算法筆記 3.2 codeup1935 查找學生信息

算法筆記 3.2 codeup1935 查找學生信息

oid swe stdio.h struct \n tdi clu gen bre

#include <stdio.h>
#include <string.h>
const int maxn = 1e3;
struct student{
    char id[10];
    char name[70];  //!!!!!!!
    char gender[3];
    int age;
} stu[maxn];
  
  
  
  
int main(void){
    int n;
    while(scanf("%d", &n)!=EOF){
    for(int i=0; i<n; i++){
        scanf("
%s %s %s %d", &stu[i].id, &stu[i].name, &stu[i].gender, &stu[i].age); } int m; scanf("%d", &m); while(m--){ char test_id[4]; scanf("%s", test_id); int i; for( i=0; i<n; i++){ if(strcmp(stu[i].id, test_id)==0){ printf(
"%s %s %s %d\n", stu[i].id, stu[i].name, stu[i].gender, stu[i].age); break; } } if (i==n) printf("No Answer!\n"); } } }

算法筆記 3.2 codeup1935 查找學生信息