解题思路:
注意事项:
参考代码:
#include<stdio.h>
typedef struct Student {
char num[20];
char name[10];
double score[3];
}STU;
void Average(STU* stu, int n);
void Highest_score(STU* stu, int n);
int main()
{
STU stu[100] = { 0 };
int n = 0;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%s%s%lf%lf%lf", &stu[i].num, &stu[i].name, &stu[i].score[0], &stu[i].score[1], &stu[i].score[2]);
}
Average(stu, n);
Highest_score(stu, n);
return 0;
}
void Average(STU* stu, int n)
{
double average[3] = { 0 };
int i = 0;
for (i = 0; i < 3; i++)
{
for(int j=0;j<n;j++)
{
average[i]+=stu[j].score[i];
}
average[i]/=n;
}
for (i = 0; i < 3; i++)
{
printf("%.0lf ", average[i]);
}
printf("\n");
}
void Highest_score(STU* stu, int n)
{
int sum[100] = { 0 };
int i = 0;
for (i = 0; i < n; i++)
{
sum[i] = stu[i].score[0] + stu[i].score[1] + stu[i].score[2];
}
int a = sum[0], b = 0;
for (i = 0; i < n; i++)
{
if (a <= sum[i])
{
a = sum[i];
b = i;
}
}
printf("%s %s %.0lf %.0lf %.0lf", stu[b].num, stu[b].name, stu[b].score[0], stu[b].score[1], stu[b].score[2]);
}
0.0分
0 人评分
点我有惊喜!你懂得!浏览:1462 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:716 |
简单的a+b (C语言代码)浏览:685 |
C二级辅导-等差数列 (C语言代码)浏览:1315 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:632 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:1432 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:565 |
用筛法求之N内的素数。 (C语言代码)浏览:890 |
字符逆序 (C语言代码)浏览:645 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:383 |