1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】16.结构体2/7-2 考试座位号.c

35 lines
749 B
C
Raw Normal View History

2024-12-16 15:44:08 +00:00
#include <stdio.h>
struct student {
char id[20]; // the problem promises that the id will not exceed 16 characters
int seat1, seat2;
};
int n, m;
struct student students[1005]; // the problem promises that the number of students will not exceed 1000
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s %d %d", students[i].id, &students[i].seat1, &students[i].seat2);
}
scanf("%d", &m);
for (int i = 0; i < m; i++) {
int seat;
scanf("%d", &seat);
for (int j = 0; j < n; j++) {
if (students[j].seat1 == seat) {
printf("%s %d\n", students[j].id, students[j].seat2);
break;
}
}
}
return 0;
}