班级成绩计算


输出每个学生三门课的平均成绩,以及平均分最高分学生数据(包括学号、班级、姓名、三门课成绩,平均分)。 格式见下。(四舍五入保留一位小数)

4
20070008 software1 wangjun 87 84 76
20070001 science1 lanxin 90 84 83
20070007 software2 wuke 94 87 86
20070003 science4 xuede 90 86 87 
------------------------------------------------------------

wangjun 82.3
lanxin 85.7
wuke 89.0
xuede 87.7
20070007 software2 wuke 94.0 87.0 86.0 89.0 


#include <stdio.h>
#include <string.h>
  
struct STU
{
    int id;
    double a;
    double b;
    double c;
    double d;
    double e;
    double avg;
};
  
int main()
{
    int n;
    int i;
    scanf("%d",&n);
    STU student[1000];
    for(i=1;i<=n;i++)
    {
        scanf("%d %lf %lf %lf %lf %lf",&student[i].id,&student[i].a,&student[i].b,
            &student[i].c,&student[i].d,&student[i].e);
  
        student[i].avg=(student[i].a+student[i].b+
            student[i].c+student[i].d+student[i].e)/5;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d %.0lf %.0lf %.0lf %.0lf %.0lf %.1lf\n",student[i].id,student[i].a,student[i].b,
            student[i].c,student[i].d,student[i].e,student[i].avg);
    }
    float num1=0,num2=0,num3=0,num4=0,num5=0;
    for(i=1;i<=n;i++)
    {
        num1=num1+student[i].a ;
        num2=num2+student[i].b ;
        num3=num3+student[i].c ;
        num4=num4+student[i].d ;
        num5=num5+student[i].e ;
          
    }
    printf("%.1lf %.1lf %.1lf %.1lf %.1lf\n",num1/n,num2/n,num3/n,num4/n,num5/n);
    return 0;
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值