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-5 找出同龄者.c

34 lines
515 B
C
Raw Permalink Normal View History

2024-12-16 15:44:08 +00:00
#include <stdio.h>
struct node {
char name[105];
int age;
};
int n, k, flag;
struct node stu[105];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s %d", stu[i].name, &stu[i].age);
}
scanf("%d", &k);
for (int i = 0; i < n; i++) {
if (stu[i].age != k) {
if (flag == 1) {
printf(" ");
} else {
flag = 1;
}
printf("%s", stu[i].name);
}
}
return 0;
}