C语言实现学神成绩管理

1、10个学生
2、四个自定义函数实现四个功能
四个功能块:
     1. 计算平均分    
     2. 统计优、良、中、及格、不及格人数及所占比例
      3. 查找最高分和最低分
      4. 分数由高到低依次排序

#include <stdio.h>
#include <stdlib.h>
#define N 30
/**
为 struct students定义了一个新的名字 STU
与 typedef struct students STU 等价
**/
typedef struct students
{
    long id;
    char name[10];
    float score;
}STU;
void addscore(STU stu[],int n);
void showscore(STU stu[],int n);
void lowTOhigh(STU stu[],int n);
void highTOlow(STU stu[],int n);
int showlist(void);
int main()
{
    char choose;
    int n;
    STU stu[N];
    printf("你想输入多少名同学的信息:");
    scanf("%d",&n);
    while(1){
        choose=showlist();
        switch(choose)
    {
        case 1:addscore(stu,n);
            break;
        case 2:showscore(stu,n);
            break;
        case 3:highTOlow(stu,n);
               showscore(stu,n);
            break;
        case 4:lowTOhigh(stu,n);
                showscore(stu,n);
            break;
        default:printf("Input error!\n");
    }
}
   return 0;
}
void addscore(STU stu[],int n){
    int i;
    printf("***请输入学生的学号、姓名和成绩:\n(注意输入一项数据按一下回车键)\n");
    for(i=0;i<n;i++){
        scanf("%ld",&stu[i].id);
        scanf("%s",stu[i].name);
        scanf("%f",&stu[i].score);
    }
}
int showlist(void){
    int choose;
    printf("1.增加学生信息\n");
    printf("2.显示所有学生信息\n");
    printf("3.成绩由高到低排序\n");
    printf("4.成绩由低到高排序\n");
    printf("\n请选择:");
    scanf("%d",&choose);
    return choose;
}
void showscore(STU stu[],int n){
    int i;
    for(i=0;i<n;i++){
        printf("%ld%5s%6.1f\n",stu[i].id,
                                stu[i].name,
                                stu[i].score);
    }
}
void highTOlow(STU stu[],int n){
    int i,j,k;
    float temp1,temp2;
    for(i=0;i<n-1;i++){
        k=i;
        for(j=i+1;j<n;j++){
            if(stu[j].score>stu[k].score) k=j;
        }
        if(k!=i){
            temp1=stu[k].score;
            stu[k].score=stu[i].score;
            stu[i].score=temp1;
            temp2=stu[k].id;
            stu[k].id=stu[i].id;
            stu[i].id=temp2;
        }
    }
}
void lowTOhigh(STU stu[],int n){
    int i,j,k;
    float temp1,temp2;
    for(i=0;i<n-1;i++){
        k=i;
        for(j=i+1;j<n;j++){
            if(stu[j].score<stu[k].score) k=j;
        }
        if(k!=i){
            temp1=stu[k].score;
            stu[k].score=stu[i].score;
            stu[i].score=temp1;
            temp2=stu[k].id;
            stu[k].id=stu[i].id;
            stu[i].id=temp2;
        }
    }
}

 这里有一些基本代码,可以参考下:

如有帮助请在我的回答上点个【采纳】