代码实现:
#include<stdio.h>
typedef struct
{
char test_number[15];
int test, exam;
}TestStudent;
int main()
{
int N, M;
TestStudent *a;
scanf("%d", &N);
a = (TestStudent*)malloc(sizeof(TestStudent)*N);
for (int i = 0; i < N; i++)scanf("%s %d %d", a[i].test_number, &a[i].test, &a[i].exam);
scanf("%d", &M);
for (int i = 0; i < M; i++)
{
int test_number;
scanf("%d", &test_number);
for (int j = 0; j < N; j++)
if (a[j].test == test_number)printf("%s %d\n", a[j].test_number, a[j].exam);
}
return 0;
}