C语言结构体数组类型相关

利用结构体数组类型
计算学生的平均成绩和不及格人数
以及讲分数从高到低整体排序


#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<stdlib.h>

struct Student {
    int id;
    char name[20];
    float score;
};


int sort(struct Student stu[])
{
    int i, j;
    for (i = 0;i < 10-1;i++) {
        for (j = 0;j < 10-i-1;j++)
        {
            if (stu[j].score < stu[j + 1].score)
            {
                struct Student temp = stu[j];
                stu[j] = stu[j + 1];
                stu[j + 1] = temp;
            }
        }
    }
}
void initStudent(struct Student* p)
{
    int i;
    for (i = 0;i < 10;i++)
    {
        //printf("输入第%d学生信息:\n", i + 1);
        scanf("%d %s %f", &p->id, p->name, &p->score);
        p++;
    }

}
int main()
{
    //{ {10101,"Zhang",78},{10103,"Wang",98.5},{10106,"Li",86},{10108,"Ling",73.5},{10110,"Fun",100}}; 
    int i;
    struct Student arry[20] = {0};
    
    initStudent(arry);
     sort(arry);
     printf("排序后:\n");
    for (i = 0; i < 10; i++)
    {
        printf("%d %s %.2f\n", arry[i].id, arry[i].name, arry[i].score);
    }
    return 0;
}