找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2010|回复: 0
打印 上一主题 下一主题
收起左侧

C语言学生成绩管理系统设计Word格式报告文档

[复制链接]
跳转到指定楼层
楼主
ID:455727 发表于 2018-12-26 18:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  • 概要设计
  • 题目简述
此程序为一个学生学籍管理系统,用户可以在程序开始运行时选择学生人数和课程人数,在输入之后便可进行操作, 计算每科的总成绩、平均成绩,计算每个人的总成绩、平均成绩,按分数排序,按学号排序,通过学号搜索信息,通过姓名搜索信息,各科成绩分析,列出所有人员信息 等功能。
2.功能模块图
  • . 选择学生人数和课程人数
  • . 计算每科的总成绩、平均成绩
  • . 计算每个人的总成绩、平均成绩
  • . 按分数排序
  • .按学号排序
  • . 通过学号搜索信息
  • . 通过姓名搜索信息
  • . 各科成绩分析
  • . 列出所有人员信息
2.详细流程
     首先定义结构体存放学生的基本属性
//结构体的定义,表示每个学生的信息
typedef struct                            //定义了一个名字叫做student的结构体
{
              int school_number;              //学号
              char name[128];                            //姓名
              float object[128];              //科目
              float total_sort;              //总成绩
              float average_sort;              //平均成绩
}student;
接着定义了四个全局变量
//定义了四个全局变量
int how_many_people;                            //多少人
int how_many_object;                            //多少科
student theClass[30],temp;              //结构体数组,表示多少个人,30可以换,temp交换用的一个结构体
char anything;                                                        //记录任意键的变量名
接着定义十个函数分别完成各个的功能,每个参数引入的形式参数
void how_many_people_and_object();
//一共几人几科
void input_record_manually();            
//输入信息依次输入学生名字以及课程科目平均成绩
void Calculate_total_and_average_score_of_every_course();              //计算每科的总成绩平均成绩 运用两个for循环统计每个科目的每个人的信息相加求出总和,除以人数求出平均值
void Calculate_total_and_average_score_of_every_student();                            //计算每个人的总成绩平均成绩,由结构体直接读出来
voidSort_in_descending_order_by_total_score_of_every_student();//按总成绩排名
用冒泡排序 将第一个元素与之后的n个元素比较,如果有比第一个元素大的元素则将其置换,继续比较,则一次比较完毕,最后一个元素是最大的,再将第二个元素与n-1个元素比较重复过程。
void Sort_in_ascending_order_by_number();              //按学号大小排名用冒泡排序 将第一个元素与之后的n个元素比较,如果有比第一个元素大的元素则将其置换,继续比较,则一次比较完毕,最后一个元素是最大的,再将第二个元素与n-1个元素比较重复过程。
void Search_by_number();//通过学号来搜索
void Search_by_name();//通过姓名来搜索
void Statistic_analysis_for_every_course();//分析各科成绩
void List_record();//列出信息
流程图:
  • 程序代码

  1. #include<stdio.h>                            //C语言的头文件
  2. #include<windows.h>                            //windows的头文件
  3. #include<conio.h>                            //控制台输入输出头文件
  4. #include<time.h>                            //时间的头文件
  5. void how_many_people_and_object();                                                                                                                //一共几人几科
  6. void input_record_manually();                                                                                                                              //输入信息
  7. void Calculate_total_and_average_score_of_every_course();                            //计算每科的总成绩平均成绩
  8. void Calculate_total_and_average_score_of_every_student();                            //计算每个人的总成绩平均成绩
  9. void Sort_in_descending_order_by_total_score_of_every_student();//按总成绩排名
  10. void Sort_in_ascending_order_by_number();                                                                                    //按学号大小排名
  11. void Search_by_number();                                                                                                                                            //通过学号来搜索
  12. void Search_by_name();                                                                                                                                                          //通过姓名来搜索
  13. void Statistic_analysis_for_every_course();                                                                                    //分析各科成绩
  14. void List_record();                                                                                                                                                                        //列出信息

  15. //结构体的定义,表示每个学生的信息
  16. typedef struct                            //定义了一个名字叫做student的结构体
  17. {
  18.               int school_number;              //学号
  19.               char name[128];                            //姓名
  20.               float object[128];              //科目
  21.               float total_sort;              //总成绩
  22.               float average_sort;              //平均成绩
  23. }student;

  24. //定义了四个全局变量
  25. int how_many_people;                            //多少人
  26. int how_many_object;                            //多少科
  27. student theClass[30],temp;              //结构体数组,表示多少个人,30可以换,temp交换用的一个结构体
  28. char anything;                                                        //记录任意键的变量名

  29. //函数的定义
  30. void how_many_people_and_object()
  31. {
  32.               printf("请输入学生人数:");
  33.               scanf("%d",&how_many_people);
  34.               printf("请输入总科目:");
  35.               scanf("%d",&how_many_object);
  36. }
  37. void input_record_manually()
  38. {
  39.               char ch;
  40.               for(int i=0;i<how_many_people;i++)
  41.               {
  42.                             printf("请输入第 %d 个人的姓名:",i+1);
  43.                             scanf("%s",&theClass[i].name);
  44.                            
  45.                             printf("请输入第 %d 个人的学号:",i+1);
  46.                             scanf("%d",&theClass[i].school_number);

  47.                             float  sum=0;
  48.                             for(int j=0;j<how_many_object;j++)
  49.                             {
  50.                                           printf("请输入第 %d 个人的第 %d 科成绩:",i+1,j+1);
  51.                                           scanf("%f",&theClass[i].object[j]);

  52.                                           sum=sum+theClass[i].object[j];
  53.                                           theClass[i].total_sort=sum;
  54.                                           theClass[i].average_sort=theClass[i].total_sort/how_many_object;                           
  55.                             }
  56.                             printf("总成绩:              %.2f\n",theClass[i].total_sort);
  57.                             printf("平均成绩:              %.2f\n",theClass[i].average_sort);
  58.               }
  59.               printf("任意键返回主菜单");
  60.               ch=getche();
  61. }
  62. void Calculate_total_and_average_score_of_every_course()
  63. {
  64.               char ch;
  65.               float total_sum=0;
  66.               float average_sum=0;
  67.               for(int j=0;j<how_many_object;j++)
  68.               {
  69.                             for(int i=0;i<how_many_people;i++)
  70.                             {
  71.                                           total_sum = theClass[i].object[j] + total_sum;
  72.                                           average_sum = total_sum / how_many_people;
  73.                             }
  74.                             printf("第 %d 科的总成绩:%.2f                            平均成绩:%.2f\n",j+1,total_sum,average_sum);
  75.                             total_sum=0;
  76.                             average_sum=0;
  77.               }
  78.             
  79.               printf("任意键返回主菜单");
  80.               ch=getche();
  81. }
  82. void Calculate_total_and_average_score_of_every_student()
  83. {
  84.               char ch;
  85.               for(int i=0;i<how_many_people;i++)
  86.               {
  87.                             printf("%s              的总成绩: %.2f              平均成绩: %.2f\n",theClass[i].name,theClass[i].total_sort,theClass[i].average_sort);
  88.               }
  89.               printf("任意键返回主菜单");
  90.               ch=getche();
  91. }
  92. void Sort_in_descending_order_by_total_score_of_every_student()
  93. {
  94.               char ch;
  95.               for(int i=0;i<how_many_people;i++)                            //冒泡排序
  96.               {
  97.                             for(int j=i+1;j<how_many_people;j++)
  98.                             {
  99.                                           if(theClass[i].total_sort<theClass[j].total_sort)
  100.                                           {
  101.                                                         temp=theClass[i];
  102.                                                         theClass[i]=theClass[j];
  103.                                                         theClass[j]=temp;
  104.                                           }
  105.                             }
  106.               }
  107.               for(int ii=0;ii<how_many_people;ii++)
  108.               {
  109.                             printf("第%d名:%s--%.2f\n",ii+1,theClass[ii].name,theClass[ii].total_sort);
  110.               }
  111.               printf("任意键返回主菜单");
  112.               ch=getche();
  113. }
  114. void Sort_in_ascending_order_by_number()
  115. {
  116.               char ch;
  117.               for(int i=0;i<how_many_people;i++)
  118.               {
  119.                             for(int j=i+1;j<how_many_people;j++)
  120.                             {
  121.                                           if(theClass[i].school_number>theClass[j].school_number)
  122.                                           {
  123.                                                         temp=theClass[i];
  124.                                                         theClass[i]=theClass[j];
  125.                                                         theClass[j]=temp;
  126.                                           }
  127.                             }
  128.               }
  129.               for(int ii=0;ii<how_many_people;ii++)
  130.               {
  131.                             printf("%d--%s--%.2f\n",theClass[ii].school_number,theClass[ii].name,theClass[ii].total_sort);
  132.               }
  133.               printf("任意键返回主菜单");
  134.               ch=getche();
  135. }
  136. void Search_by_number()
  137. {
  138.               char ch;
  139.               int number;
  140.               printf("请输入学号:");
  141.               scanf("%d",&number);
  142.               system("cls");
  143.               for(int i=0;i<how_many_people;i++)
  144.               {
  145.                             if(number - theClass[i].school_number == 0)
  146.                             {
  147.                                           printf("姓名:%s\n",theClass[i].name);
  148.                                           printf("学号:%d\n",theClass[i].school_number);
  149.                                           for(int j=0;j<how_many_object;j++)
  150.                                           {
  151.                                                         printf("第 %d 科成绩:%.2f\n",j+1,theClass[i].object[j]);
  152.                                           }
  153.                                           printf("总成绩:%.2f\n平均成绩:%.2f\n\n",theClass[i].total_sort,theClass[i].average_sort);
  154.                             }
  155.               }
  156.               printf("任意键返回主菜单");
  157.               ch=getche();
  158. }
  159. void Search_by_name()
  160. {
  161.               char ch;
  162.               char n[128];
  163.               printf("请输入姓名:");
  164.               scanf("%s",&n);
  165.               for(int i=0;i<how_many_people;i++)
  166.               {
  167.                             if(strcmp(n,theClass[i].name)==0)
  168.                             {
  169.                                           printf("姓名:%s\n",theClass[i].name);
  170.                                           printf("学号:%d\n",theClass[i].school_number);
  171.                                           for(int j=0;j<how_many_object;j++)
  172.                                           {
  173.                                                         printf("第 %d科成绩:%.2f\n",j+1,theClass[i].object[j]);
  174.                                           }
  175.                                           printf("总成绩:%.2f\n平均成绩:%.2f\n",theClass[i].total_sort,theClass[i].average_sort);
  176.                             }
  177.               }
  178.               printf("任意键返回主菜单");
  179.               ch=getche();
  180. }
  181. void Statistic_analysis_for_every_course()
  182. {
  183.               char ch;
  184.               float a[6][6]={0};                            //第几科的第几类成绩(优良中差及不及),最大为6课,可以改
  185.               for(int i=0;i<how_many_people;i++)
  186.               {
  187.                             for(int j=0;j<how_many_object;j++)
  188.                             {
  189.                                           if(theClass[i].object[j]>=90  &&  theClass[i].object[j]<=100)
  190.                                                         a[j][0]++;
  191.                                           else if(theClass[i].object[j]>=80  &&  theClass[i].object[j]<=89)
  192.                                                         a[j][1]++;
  193.                                           else if(theClass[i].object[j]>=70  &&  theClass[i].object[j]<=79)
  194.                                                         a[j][2]++;
  195.                                           else if(theClass[i].object[j]>=60  &&  theClass[i].object[j]<=69)
  196.                                                         a[j][3]++;
  197.                                           else
  198.                                                         a[j][4]++;
  199.                             }
  200.               }
  201.               for(int j=0;j<how_many_object;j++)
  202.               {
  203.                             printf("第 %d 科优秀的人数是:%.2f 所占百分比是:%.0f %%\n",j+1,a[j][0],a[j][0]/how_many_people*100);
  204.                             printf("第 %d 科良好的人数是:%.2f 所占百分比是:%.0f %%\n",j+1,a[j][1],a[j][1]/how_many_people*100);
  205.                             printf("第 %d 科中等的人数是:%.2f 所占百分比是:%.0f %%\n",j+1,a[j][2],a[j][2]/how_many_people*100);
  206.                             printf("第 %d 科及格的人数是:%.2f 所占百分比是:%.0f %%\n",j+1,a[j][3],a[j][3]/how_many_people*100);
  207.                             printf("第 %d 科不及的人数是:%.2f 所占百分比是:%.0f %%\n\n",j+1,a[j][4],a[j][4]/how_many_people*100);
  208.               }
  209.               printf("任意键返回主菜单");
  210.               ch=getche();
  211. }
  212. void List_record()
  213. {
  214.               char ch;
  215.               for(int i=0;i<how_many_people;i++)
  216.               {
  217.                             printf("%s\n",theClass[i].name);
  218.                             printf("%d号\n",theClass[i].school_number);

  219.                             for(int j=0;j<how_many_object;j++)
  220.                             {
  221.                                           printf("第 %d 科成绩:%.2f\n",j+1,theClass[i].object[j]);
  222.                             }
  223.                             printf("总成绩:%.2f\n平均成绩:%.2f\n\n",theClass[i].total_sort,theClass[i].average_sort);
  224.               }
  225.               printf("任意键返回主菜单");
  226.               ch=getche();
  227. }

  228. //主函数
  229. int main()
  230. {
  231.               int choise;
  232.             
  233.             
  234.               printf("学生成绩管理系统\n\n");
  235.               how_many_people_and_object();

  236.               part:
  237.               system("cls");
  238.               printf("1.Input record manually\n");
  239.               printf("2.Calculate total and average score of every course\n");
  240.               printf("3.Calculate total and average score of every student\n");
  241.               printf("4.Sort in descending order by total score of every student\n");
  242.               printf("5.Sort in ascending order by number\n");
  243.               printf("6.Search by number\n");
  244.               printf("7.Search by name\n");
  245.               printf("8.Statistic analysis for every course\n");
  246.               printf("9.List record\n");
  247.               printf("0.Exit\n");
  248.               printf("Please input your choice:");
  249.               scanf("%d",&choise);
  250.               if(choise==1)
  251.                             {
  252.                                           system("cls");
  253.                                           input_record_manually();
  254.                                           goto part;
  255.                             }
  256.               else if(choise==2)
  257.                             {
  258.                                           system("cls");
  259.                                           Calculate_total_and_average_score_of_every_course();
  260.                                           goto part;
  261.                             }
  262.               else if(choise==3)
  263.                             {
  264.                                           system("cls");
  265.                                           Calculate_total_and_average_score_of_every_student();
  266.                                           goto part;
  267.                             }
  268.               else if(choise==4)
  269.                             {
  270.                                           system("cls");
  271.                                           Sort_in_descending_order_by_total_score_of_every_student();
  272.                                           goto part;
  273.                             }
  274.               else if(choise==5)
  275.                             {
  276.                                           system("cls");
  277.                                           Sort_in_ascending_order_by_number();
  278.                                           goto part;
  279.                             }
  280.               else if(choise==6)
  281.                             {
  282.                                           system("cls");
  283.                                           Search_by_number();
  284.                                           goto part;
  285.                             }
  286.               else if(choise==7)
  287.                             {
  288.                                           system("cls");
  289.                                           Search_by_name();
  290.                                           goto part;
  291.                             }
  292.               else if(choise==8)
  293.                             {
  294.                                           system("cls");
  295.                                           Statistic_analysis_for_every_course();
  296.                                           goto part;
  297.                             }
  298.               else if(choise==9)
  299.                             {
  300.                                           system("cls");
  301.                                           List_record();
  302.                                           goto part;
  303.                             }
  304.               else if(choise==0)
  305.                             return 0;
  306.               else
  307.                             ;
  308. return 0;
  309. }
复制代码

4.技术关键和设计心得
在这次课程设计中,我们首先对系统的整体功能进行了构思,然后用结构化分析方法进行分析,将整个系统清楚的划分为几个模块,再根据每个模块的功能编写代码。而且尽可能的将模块细分,最后在进行函数的调用。我们在函数的编写过程中,我们不仅用到了for循环、while循环和switch语句,还用到了函数之间的调用(包括递归调用)。由于我们是分工编写代码,最后需要将每个人的代码放到一起进行调试。因为我们每个人写的函数的思想不都一样,所以在调试的过程中也遇到了困难,但经过我们耐心的修改,终于功夫不负有心人,我们成功了!

完整的Word格式文档51黑下载地址:
学生学籍管理系统 - 副本.docx (56.68 KB, 下载次数: 9)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表