1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include <stdio.h>
- int main() {
- int n;
- scanf("%d", &n);
-
- struct student {
- int num;
- char name[20];
- int score[3];
- } students[100];
-
- int i, j;
- for (i = 0; i < n; i++) {
- scanf("%d %s %d %d %d", &students[i].num, students[i].name, &students[i].score[0], &students[i].score[1], &students[i].score[2]);
- }
-
- int total_score[3] = {0};
- for (i = 0; i < n; i++) {
- for (j = 0; j < 3; j++) {
- total_score[j] += students[i].score[j];
- }
- }
- float avg_score[3];
- int max_score[3] = {0};
- for (j = 0; j < 3; j++) {
- avg_score[j] = total_score[j] / (float)n;
- for (i = 0; i < n; i++) {
- if (students[i].score[j] > max_score[j]) {
- max_score[j] = students[i].score[j];
- }
- }
- }
- for (j = 0; j < 3; j++) {
- printf("aver=%.0fmax=%d\n", avg_score[j], max_score[j]);
- }
-
- return 0;
- }
|