c语言学生成绩管理系统

某班有最多不超过40名学生参加期末考试,具体人数由键盘输入,考试科目为数学、英语和物理。试编程实现对学生期末考试成绩进行管理。功能和编程要求如下:

(1)用结构体存放每个学生的信息,包括学号、姓名、3门课程的成绩、总分、平均分和排名。

(2)能通过键盘录入学生信息,包括学号、姓名和3门课程的成绩。

(3)能计算每名学生的总分和平均分。

(4)能按总分成绩由高到低排出名次。(总成绩相同的学生之间排序不作具体要求)。

(5)能按总分成绩由高到低输出学生信息,输出信息顺序为:学号、姓名、数学成绩、英语成绩、物理成绩、总分、平均分、排名。

(6)能按学号升序输出学生信息,输出信息顺序与(4)同。

(7)能按姓名升序输出学生信息,输出信息顺序与(4)同。

(8)能根据学号查询并输出某学生的信息,输出信息顺序与(4)同。

(9)能根据姓名查询并输出某学生的信息,输出信息顺序与(4)同。

(10)能输出总成绩最高和最低的学生信息,输出信息顺序与(4)同。

(11)能将学生信息存储到磁盘文件中。

(12)能将学生信息从磁盘文件中读出到程序中。

(13)程序运行后先显示如下菜单,提示用户输入选项完成相应的功能。

1.nput records.

2.Sort in ascending order by number and output records.3.Sort in descending order by total score and output records.4.Sort in ascending order by name and output records.

5.Search by number and output the record.

6.Search by name and output the record.

7.0utput the highest and lowest student records.

8.Store student information in disk fle.

9.Read the student information from the disk fle.

0.Exi

Please enter your choice:

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

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

#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;
        }
    }
}

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps: 问答会员年卡【8折】购 ,限时加赠IT实体书,即可 享受50次 有问必答服务,了解详情>>>https://t.csdnimg.cn/RW5m