Marko


私信TA

用户名:1152616455

访问量:11872

签 名:

等  级
排  名 1280
经  验 2911
参赛次数 1
文章发表 15
年  龄 0
在职情况 学生
学  校 河北工业大学
专  业

  自我简介:

#include <stdio.h>

#define N 100


struct stu {

char name[10];

char num[10];

int score[3];

};


int i;


void get(struct stu *st,int n)

{

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

        scanf("%s %s %d %d %d",st[i].name,st[i].num,st[i].score,st[i].score+1,st[i].score+2);

}

void average(struct stu *st,int n)

{

    int sum[3]={0,0,0};

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

        {

            sum[0]+=st[i].score[0];

            sum[1]+=st[i].score[1];

            sum[2]+=st[i].score[2];

        }

        sum[0]/=n;

        sum[1]/=n;

        sum[2]/=n;

        printf("%d %d %d\n",sum[0],sum[1],sum[2]);

}

void max(struct stu *st,int n)

{

    int sum,max,s=0;

    sum=st[0].score[0]+st[0].score[1]+st[0].score[2];

    max=0;

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

    {

        s=st[i].score[0]+st[i].score[1]+st[i].score[2];

        if(s>sum)

        {

            sum=s;

            max=i;

        }

    }

    printf("%s %s %d %d %d"              ,st[max].name,st[max].num,st[max].score[0],st[max].score[1],st[max].score[2]);

}

int main (void)

{

    struct stu st[N];

    int n;

    scanf("%d",&n);

    get(st,n);

    average(st,n);

    max(st,n);


    return 0;

}





 

0.0分

1 人评分

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

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区