//假设一个年级有三个班级,每个班级有四十名学生。考试后。学校要从这些学生的考试成绩中找出不及格的学生成绩
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {
struct student {
int sorce;
};
struct class {
struct student students[40];
};
struct class C[3];
int i,j,n;
n=1;
for (i = 0; i<3; i++) {
printf("请输入%d班的分数,用空格隔开每个分数",n);
for (j = 0;j<40; j++) {
scanf("%d", &(C[i].students[j].sorce));
}
n++;
}
n=1;
for (i = 0; i<3; i++) {
printf("%d班不及格的分数",n);
for (j = 0;j<40; j++) {
if (C[i].students[j].sorce<60) {
printf("%3d", (C[i].students[j].sorce));
}
}
n++;
printf("\n");
}
return 0;
} |
|