基础结构体问题
#include <stdio.h>
struct student{
char num[10];
char name[20];
char sex[10];
int age;
};
int main() {
int n;
while (scanf("%d",&n)!=EOF) { // 注意 while 处理多个 case
struct student stu[n];
for (int i = 0; i < n; i++){
scanf("%s %s %s %d", stu[i].num, stu[i].name, stu[i].sex, &stu[i].age);
}
int m,j;
char t[10];
scanf("%d", &m);
for (int i = 0; i < m; i++){
scanf("%s", t);
for (j = 0; j < n; j++){
if (strcmp(stu[j].num,t) == 0){
printf("%s %s %s %d\n", stu[j].num, stu[j].name, stu[j].sex, stu[j].age);
break;
}
}
if (j == n) printf("No Answer!\n");
}
}
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号