• 大小: 12KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: C/C++
  • 标签: stu.c  

资源简介

C语言入门,学生成绩管理系统,使用结构体数组储存数据,可以根据姓名,分数排序,统计不同科目的平均分等等。

资源截图

代码片段和文件信息

#include
#include
typedef struct student_achievement
{
    char name[21];
    int  numberorder;
    float average_scoretotal_scorescore[6];
} AC;
AC student[30];
void input(AC *achievementint Nint M)                                   //输入函数
{
    int ik;
    for( i=0k=1; i    {
        printf(“Please input student%d numbernamescore:\n“i+1);
        AC *student1=achievement+i;
        float total=0average;
        while(k==1)
        {
            printf(“number:“);
            scanf(“%d“&student1->number);
            if(getchar()!=10)
            {
                printf(“Input error!\n“);                                 //输入错误提示
                fflush(stdin);                                            //清除缓冲区
            }
            else
                break;
        }
        while(k==1)
        {
            printf(“name:“);
            scanf(“%s“&student1->name);
            if(getchar()!=10)
            {
                printf(“Input error!\n“);                                 //输入错误提示
                fflush(stdin);                                             //清除缓冲区
            }
            else
                break;
        }
        while(k==1)
        {
            printf(“each course score:“);
            int j;
            for(j=0; j                scanf(“%f“&student1->score[j]);
            if(getchar()!=10)
            {
                printf(“Input error!\n“);                                 //输入错误提示
                fflush(stdin);                                            //清除缓冲区
            }
            else
                break;
        }
        int j;
        for(j=0; j            total=total+(student1->score[j]);
        average=total/M;
        (student1->total_score)=total;
        (student1->average_score)=average;
    }
    float a[30]b[30];                                                  //冒泡排序求排名
    for(i=0; i    {
        a[i]=(achievement+i)->total_score;
        b[i]=i+1;
    }
    while(k==0)
    {
        k=1;
        float j;
        for(i=0; i            if(a[i]            {
                j=a[i+1];
                a[i+1]=a[i];
                a[i]=j;
                j=b[i+1];
                b[i+1]=b[i];
                b[i]=j;
                k=0;
            }
    }
    for(i=0; i        (achievement+i)-> order=b[i];
    printf(“\nInput record success!\n“);
}
void score_of_course(AC achievement[]int Nint M)                       //函数2:计算每门课程的总分和平均分
{
    float total[6]average[6];
    int ij;
    for(i=0; i    {
        total[i]=0;
        for(j=0; j            total[i]=total[i]+achievement[j].score[i];
    }
    for(i=0; i        average[i]=total[i

评论

共有 条评论

相关资源