题解 | #查找学生信息#
查找学生信息
https://www.nowcoder.com/practice/fe8bff0750c8448081759f3ee0d86bb4
#include<stdio.h> struct student { int no; char name[20]; char sex[10]; int age; } ; student s[1005]; int main() { int n, m, i, j; scanf("%d", &n); for (i = 0; i < n; ++i) { scanf("%d%s%s%d", &s[i].no, &s[i].name, &s[i].sex, &s[i].age); } scanf("%d", &m); int k; for ( i = 0; i < m; ++i) { scanf("%d", &k); for ( j = 0; j < n; ++j) { if (k == s[j].no) { printf("%d %s %s %d\n", s[j].no, s[j].name, s[j].sex, s[j].age); break; } } if (j == n) { printf("No Answer!\n"); } } return 0; }