花开若相惜


私信TA

用户名:uq_78154707512

访问量:6382

签 名:

等  级
排  名 951
经  验 3305
参赛次数 0
文章发表 38
年  龄 22
在职情况 学生
学  校
专  业 通信工程

  自我简介:

刷题中!!!

解题思路:

注意事项:

参考代码:

typedef struct student{

  char id[100];

  char name[100];

  int score[3],allscore;

}stu[100];

void input(int n)

{

    struct student stu[100];

    int i,t=0;

    for(i=0;i<n;i++)

    {

        scanf("%s %s %d %d %d",stu[i].id,stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);

        stu[i].allscore=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];

    }

    int max;

    int a1=stu[0].score[0],a2=stu[0].score[1],a3=stu[0].score[2];

    max=stu[0].allscore;

    for(i=1;i<n;i++)

    {

        if(max<stu[i].allscore)

        {

            max=stu[i].allscore;

            t=i;

        }

        a1=a1+stu[i].score[0];//求所有同学这门课的总分;

        a2=a2+stu[i].score[1];

        a3=a3+stu[i].score[2];

    }

    printf("%d %d %d\n",a1/n,a2/n,a3/n);

    printf("%s %s %d %d %d",stu[t].id,stu[t].name,stu[t].score[0],stu[t].score[1],stu[t].score[2]);

}

int main()

{

    int n;

    scanf("%d",&n);

    input(n);

    return 0;

}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区