c语言进阶-学生成绩统计系统实现(内含源代码)

C语言进阶

  (一)前言:

       在学习c语言基础语法后我们需要通过项目的训练进行进阶提升,一个小的项目能够使初学者对编程语言掌握的更牢固、进一步熟悉编程的逻辑,所以在这里例出了项目的题目要求、算法分析以及完整的程序代码供初学者学习。

 

(二)题目要求:学生成绩统计系统实现

  设计结构体数组,结构中包含学生数据为:学号、姓名、物理分数、数学分数、外语分数、计算机分数。

设计各个函数,分别实现以下功能:

(1)录入:输入学生数据

(2)显示:所有学生信息

(3)统计:统计每科的最高分、最低分;输出不及格人数、不及格学生数据。

设计菜单,通过选择菜单调用以上各函数。

 

(三)算法设计:

设计结构体数组,结构中包含学生数据为:学号、姓名、物理分数、数学分数、外语分数、计算机分数。

设计各个函数,分别实现以下功能:

(1)录入:输入学生数据

(2)显示:所有学生信息

(3)统计:统计每科的最高分、最低分;输出不及格人数、不及格学生数据。

设计菜单,通过选择菜单调用以上各函数

         <1>介绍每个函数功能:

         int main():运用switch选择,调用所需要实现相应功能的函数。

         int choose_carte():显示选择菜单,让使用者对系统的功能有更好的了解和操作。

         int Intput(struct Student stu[],int n):实现对学生成员的数据输入。

         int Output(struct Student stu[],int n):实现对已输入学生成员的输出。

         void Data(struct Student stu[],int n):实现判断对已输入学生成员的各科最高分和最低分,还有不及格学生的显示。

 

(四)完整代码实现

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

struct Student         #自定义结构体
{
    int      number;
    char     name[10];
    int      phy;
    int      math;
    int      eng;
    int      com;
}stu[40];


int choose_carte()   #菜单显示
{   int c;
do{ system("cls");
    printf("\t\t*********请选择该学生成绩统计系统所实现功能*********\n");
    printf("\t\t*1.录入:输入学生数据                              *\n");
    printf("\t\t*2.显示:显示学生数据                              *\n");
    printf("\t\t*3.统计:统计最高分,最低分                        *\n");
    printf("\t\t*0.退出                                            *\n");
    printf("\t\t****************************************************\n");
    printf("\t\t\tGive you Choice(0-3):");
    scanf("%d",&c);
}while(c<0||c>3);
    return c;
}


int Intput(struct Student stu[],int n)    #输入学生信息
{
    int i=0;
    char  c;
    do
    {
    printf("\t\t\t学号:");
    scanf("\t\t\t%d",&stu[n+i].number);
    printf("\t\t\t姓名:");
    scanf("\t\t\t%s",&stu[n+i].name);
    printf("\t\t\t物理分数:");
    scanf("\t\t\t%d",&stu[n+i].phy);
    printf("\t\t\t数学分数:");
    scanf("\t\t\t%d",&stu[n+i].math);
    printf("\t\t\t外语分数:");
    scanf("\t\t\t%d",&stu[n+i].eng);
    printf("\t\t\t计算机分数:");
    scanf("\t\t\t%d",&stu[n+i].com);
    i++;
    printf("\t\t\t您还要继续录入成绩吗?\n");
    printf("\t\t\t请输入‘y’继续,或'n'停止");
    scanf("\t\t\t%c",&c);
    }while(c=='y');
    return (i+n);
    }



int Output(struct Student stu[],int n)       #输出学生信息
{
    int i;
    printf("\t\t----------------------------------------------------\n");
    printf("\t\t| Number |  Name  |  Phy  |  Math |  Eng  |  Com  | \n");
    printf("\t\t----------------------------------------------------\n");
    for( i=1;i<n+1;i++)
    {
        printf("\t\t%4d%10s%9d%9d%9d%9d\n",stu[i-1].number,stu[i-1].name,stu[i-1].phy,stu[i-1].math,stu[i-1].eng,stu[i-1].com);
        printf("\t\t----------------------------------------------------\n");
    }
     system("pause");

}


void Data(struct Student stu[],int n) #统计
{
    int i;
    int sum=0;
    int phy_hight=0;
    int math_hight=0;
    int eng_hight=0;
    int com_hight=0;
    int phy_low=0;
    int math_low=0;
    int eng_low=0;
    int com_low=0;
    for(i=0;i<n;i++)
    {
        if(stu[phy_hight].phy<stu[i].phy)
            phy_hight=i;
        if(stu[phy_low].phy>stu[i].phy)
            phy_low=i;
           if(stu[i].phy<60)
            printf("\t\t物理不及格的%4d%10s%9d\n",stu[i].number,stu[i].name,stu[i].phy);

        if(stu[math_hight].math<stu[i].math)
            math_hight=i;
        if(stu[math_low].math>stu[i].math)
            math_low=i;
           if(stu[i].math<60)
            printf("\t\t数学不及格的%4d%10s%9d\n",stu[i].number,stu[i].name,stu[i].math);

        if(stu[eng_hight].eng<stu[i].eng)
            eng_hight=i;
        if(stu[eng_low].eng>stu[i].eng)
            eng_low=i;
            if(stu[i].eng<60)
            printf("\t\t英语不及格的%4d%10s%9d\n",stu[i].number,stu[i].name,stu[i].eng);

        if(stu[com_hight].com<stu[i].com)
            com_hight=i;
        if(stu[com_low].com>stu[i].com)
            com_low=i;
            if(stu[i].phy<60)
           printf("\t\t计算机不及格的%4d%10s%9d\n",stu[i].number,stu[i].name,stu[i].com);
            ++sum;
        }
    printf("\t\t该数据中不及格的人数为%d\n",sum);
    system("pause");
    printf("\t\t物理最高分为:\n");
    printf("\t\t%4d%10s%9d\n",stu[phy_hight].number,stu[phy_hight].name,stu[phy_hight].phy);
    printf("\t\t数学最高分为:\n");
    printf("\t\t%4d%10s%9d\n",stu[math_hight].number,stu[math_hight].name,stu[math_hight].math);
    printf("\t\t外语最高分为:\n");
    printf("\t\t%4d%10s%9d\n",stu[eng_hight].number,stu[eng_hight].name,stu[eng_hight].eng);
    printf("\t\t计算机最高分为:\n");
    printf("\t\t%4d%10s%9d",stu[com_hight].number,stu[com_hight].name,stu[com_hight].com);
    printf("\n\n\n");

    printf("\t\t物理最低分为:\n");
    printf("\t\t%4d%10s%9d\n",stu[phy_low].number,stu[phy_low].name,stu[phy_low].phy);
    printf("\t\t数学最低分低为:\n");
    printf("\t\t%4d%10s%9d\n",stu[math_low].number,stu[math_low].name,stu[math_low].math);
    printf("\t\t外语最低分为:\n");
    printf("\t\t%4d%10s%9d\n",stu[eng_low].number,stu[eng_low].name,stu[eng_low].eng);
    printf("\t\t计算机最低分为:\n");
    printf("\t\t%4d%10s%9d\n",stu[com_low].number,stu[com_low].name,stu[com_low].com);
    system("pause");

    }





void main()
{
    int n=0;
    do{
 switch(choose_carte())
    {
        case 0:
            break;
        case 1:
            printf("\t\t\t请输入学生的个人信息\n");
            n=Intput(stu,n);
            break;
        case 2:
            printf("\t\t\t输出所有学生的个人信息\n");
            Output(stu,n);
            break;
        case 3:
            Data(stu,n);
            break;
    }

   }while(choose_carte()!=0);
}

 

(五)结果展示

(六)项目小结

        要熟练掌握循环用来控制显示面板和所要调用的函数,结构清晰有便于后期系统的调试和运行,要使用暂停函数system("pause");让数据停留,综合性非常高,也需要对每个数据非常严谨的编写。

 

 

 

 

  • 14
    点赞
  • 144
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值