有谁帮我看看么,一道C的问题

有谁帮我看看么,一道C的问题,请帮我直接用代码解出来,好的必定采纳

img

定义个学生结构体吧。

#include <stdio.h>
typedef struct _student
{
    int num;
    int score[4];
    int total;
    float avg;
}student;

void input(student *stu,int n)
{
    for(int i=0;i<n;i++)
        scanf("%d %d,%d,%d,%d",&stu[i].num,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2],&stu[i].score[3]);
}

void calc(student *stu,int n)
{
    for(int i=0;i<n;i++)
    {
        stu[i].total = stu[i].score[0] + stu[i].score[1] + stu[i].score[02] + stu[i].score[3];
        stu[i].avg = stu[i].total/4.0;
    }
}

void sort(student *stu,int n)
{
    student t;
    for(int i=0;i<n-1;i++)
    {
        for(int j=0;j<n-1-i;j++)
        {
            if(stu[j].total < stu[j+1].total)
            {
                t = stu[j];
                stu[j] = stu[j+1];
                stu[j+1] = t;
            }
        }
    }
    int k = 0;
    for(int i=0;i<n;i++)
    {
        if(i==0 || stu[i].total != stu[i-1].total)
            k++;
        printf("%d %d %d %d %d %d %.1f\n",k,stu[i].num,stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3],stu[i].avg);
    }
}

int main()
{
    student stu[3];
    input(stu,3);
    calc(stu,3);
    sort(stu,3);
    return 0;
}

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632