题目内容:
某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用二维字符数组作函数参数编程实现如下菜单驱动的学生成绩管理系统:
(1)录入每个学生的学号、姓名和考试成绩;
(2)计算课程的总分和平均分;
(3)按成绩由高到低排出名次表;
(4)按成绩由低到高排出名次表;
(5)按学号由小到大排出成绩表;
(6)按姓名的字典顺序排出成绩表;
(7)按学号查询学生排名及其考试成绩;
(8)按姓名查询学生排名及其考试成绩;
(9)按优秀(90~ 100)、良好(80~ 89)、中等(70~ 79)、及格(60~ 69)、不及格(0~ 59)5个类别,统计每个类别的人数以及所占的百分比;
(10)输出每个学生的学号、姓名、考试成绩。
要求程序运行后先显示如下菜单,并提示用户输入选项:
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please enter your choice:
然后,根据用户输入的选项执行相应的操作。

请按照下面的定义及函数原型编程:
#define MAX_LEN 10 /* 字符串最大长度 /
#define STU_NUM 30 / 最多的学生人数 */
int Menu(void);
void ReadScore(long num[], char name[][MAX_LEN], float score[], int n);
void AverSumofScore(float score[], int n);
void SortbyScore(long num[], char name[][MAX_LEN], float score[], int n,
int (*compare)(float a, float b));
int Ascending(float a, float b);
int Descending(float a, float b);
void SwapFloat(float *x, float *y);
void SwapLong(long *x, long *y);
void SwapChar(char x[], char y[]);
void AsSortbyNum(long num[], char name[][MAX_LEN], float score[], int n);
void SortbyName(long num[], char name[][MAX_LEN], float score[], int n);
void SearchbyNum(long num[], char name[][MAX_LEN], float score[], int n);
void SearchbyName(long num[], char name[][MAX_LEN], float score[], int n);
void StatisticAnalysis(float score[], int n);
void PrintScore(long num[], char name[][MAX_LEN], float score[], int n) ;

程序运行结果示例:
Input student number(n<30):
6↙
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
1↙
Input student’s ID, name and score:
11003001↙
lisi↙
87↙
11003005↙
heli↙
98↙
11003003↙
ludi↙
75↙
11003002↙
dumo↙
48↙
11003004↙
zuma↙
65↙
11003006↙
suyu↙
100↙
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
2↙
sum=473,aver=78.83
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
3↙
Sort in descending order by score:
11003006 suyu 100
11003005 heli 98
11003001 lisi 87
11003003 ludi 75
11003004 zuma 65
11003002 dumo 48
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
4↙
Sort in ascending order by score:
11003002 dumo 48
11003004 zuma 65
11003003 ludi 75
11003001 lisi 87
11003005 heli 98
11003006 suyu 100
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
5↙
Sort in ascending order by number:
11003001 lisi 87
11003002 dumo 48
11003003 ludi 75
11003004 zuma 65
11003005 heli 98
11003006 suyu 100
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
6↙
Sort in dictionary order by name:
11003002 dumo 48
11003005 heli 98
11003001 lisi 87
11003003 ludi 75
11003006 suyu 100
11003004 zuma 65
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
7↙
Input the number you want to search:
11003004↙
11003004 zuma 65
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
8↙
Input the name you want to search:
heli↙
11003005 heli 98
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
9↙
<60 1 16.67%
60-69 1 16.67%
70-79 1 16.67%
80-89 1 16.67%
90-99 1 16.67%
100 1 16.67%
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
10↙
11003002 dumo 48
11003005 heli 98
11003001 lisi 87
11003003 ludi 75
11003006 suyu 100
11003004 zuma 65
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
11↙
Input error!
Management for Students’ scores
1.Input record
2.Caculate total and average score of course
3.Sort in descending order by score
4.Sort in ascending order by score
5.Sort in ascending order by number
6.Sort in dictionary order by name
7.Search by number
8.Search by name
9.Statistic analysis
10.List record
0.Exit
Please Input your choice:
0↙
End of program!

代码实现

#include <stdio.h>
#include <string.h>
#define   MAX_LEN  10           /* 字符串最大长度 */
#define   STU_NUM 30         /* 最多的学生人数 */
int   Menu(void);           /*输出题设菜单并输入选择*/
void  ReadScore(long num[], char name[][MAX_LEN], float score[], int n);            /*选项1 录入每个学生的学号、姓名和考试成绩*/
void  AverSumofScore(float score[], int n);         /*选项2 计算课程的总分和平均分*/
void  SortbyScore(long num[], char name[][MAX_LEN], float score[], int n,int (*compare)(float a, float b));         /*选项3.4 按成绩排出名次表*/
int   Ascending(float a, float b);           /*返回a>b是否为真*/
int   Descending(float a, float b);          /*返回a<b是否为真*/
void  SwapFloat(float *x, float *y);         /*转换*x,*y对应的值*/
void  SwapLong(long *x, long *y);         /*转换*x,*y对应的值*/
void  SwapChar(char x[], char y[]);         /*转换x[],y[]对应的值*/
void  AsSortbyNum(long num[], char name[][MAX_LEN], float score[], int n);           /*选项5 按学号由小到大排出成绩表*/
void  SortbyName(long num[], char name[][MAX_LEN], float score[], int n);            /*选项6 按姓名的字典顺序排出成绩表*/
void  SearchbyNum(long num[], char name[][MAX_LEN], float score[], int n);           /*选项7 按学号查询学生排名及其考试成绩*/
void  SearchbyName(long num[], char name[][MAX_LEN], float score[], int n);          /*选项8 按姓名查询学生排名及其考试成绩*/
void  StatisticAnalysis(float score[], int n);           /*选项9 输出百分比*/
void  PrintScore(long num[], char name[][MAX_LEN], float score[], int n);            /*输出每个学生的学号、姓名和考试成绩*/
int main()
{long num[STU_NUM];float score[STU_NUM];char name[STU_NUM][MAX_LEN];int n, co;printf("Input student number(n<30):\n");scanf("%d", &n);while(1){co=Menu();switch(co){case 1:ReadScore(num, name, score, n);break;case 2:AverSumofScore(score, n);break;case 3:SortbyScore(num, name, score, n, Descending);printf("Sort in descending order by score:\n");PrintScore(num, name, score, n);break;case 4:SortbyScore(num, name, score, n, Ascending);printf("Sort in ascending order by score:\n");PrintScore(num, name, score, n);break;case 5:AsSortbyNum(num, name, score, n);printf("Sort in ascending order by number:\n");PrintScore(num, name, score, n);break;case 6:SortbyName(num, name, score, n);printf("Sort in dictionary order by name:\n");PrintScore(num, name, score, n);break;case 7:SearchbyNum(num, name, score, n);break;case 8:SearchbyName(num, name, score, n);break;case 9:StatisticAnalysis(score, n);break;case 10:PrintScore(num, name, score, n);break;case 0:printf("End of program!");exit(0);default :printf("Input error!\n");}}
}
int   Menu(void)           /*输出题设菜单并输入选择*/
{int co;printf("Management for Students' scores\n\
1.Input record\n\
2.Caculate total and average score of course\n\
3.Sort in descending order by score\n\
4.Sort in ascending order by score\n\
5.Sort in ascending order by number\n\
6.Sort in dictionary order by name\n\
7.Search by number\n\
8.Search by name\n\
9.Statistic analysis\n\
10.List record\n\
0.Exit\n\
Please Input your choice:\n");scanf("%d", &co);return co;
}
void  ReadScore(long num[], char name[][MAX_LEN], float score[], int n)         /*选项1 录入每个学生的学号、姓名和考试成绩*/
{int i;printf("Input student's ID, name and score:\n");for(i=0; i<n; i++){scanf("%ld%s%f", &num[i], name[i], &score[i]);}
}
void  AverSumofScore(float score[], int n)          /*选项2 计算课程的总分和平均分*/
{float sum=0;int i;for(i=0; i<n; i++){sum+=score[i];}printf("sum=%.0f,aver=%.2f\n", sum, sum/n);
}
void  SortbyScore(long num[], char name[][MAX_LEN], float score[], int n,int (*compare)(float a, float b))         /*选项3.4 按成绩排出名次表*/
{int i, j;for(i=0; i<n-1; i++){for(j=i+1; j<n; j++){if((*compare)(score[i], score[j])){SwapFloat(&score[i], &score[j]);SwapChar(name[i], name[j]);SwapLong(&num[i], &num[j]);}}}
}
int   Ascending(float a, float b)           /*返回a>b是否为真*/
{return a>b;
}
int   Descending(float a, float b)          /*返回a<b是否为真*/
{return a<b;
}
void  SwapFloat(float *x, float *y)         /*转换*x,*y对应的值*/
{float temp;temp=*x;*x=*y;*y=temp;
}
void  SwapLong(long *x, long *y)         /*转换*x,*y对应的值*/
{long temp;temp=*x;*x=*y;*y=temp;}
void  SwapChar(char x[], char y[])         /*转换x[],y[]对应的值*/
{char temp[MAX_LEN];strcpy(temp, x);strcpy(x, y);strcpy(y, temp);
}
void  AsSortbyNum(long num[], char name[][MAX_LEN], float score[], int n)           /*选项5 按学号由小到大排出成绩表*/
{int i, j;for(i=0; i<n-1; i++){for(j=i+1; j<n; j++){if(num[i]>num[j]){SwapFloat(&score[i], &score[j]);SwapChar(name[i], name[j]);SwapLong(&num[i], &num[j]);}}}
}
void  SortbyName(long num[], char name[][MAX_LEN], float score[], int n)            /*选项6 按姓名的字典顺序排出成绩表*/
{int i, j;for(i=0; i<n-1; i++){for(j=i+1; j<n; j++){if(strcmp(name[i], name[j])>0){SwapFloat(&score[i], &score[j]);SwapChar(name[i], name[j]);SwapLong(&num[i], &num[j]);}}}
}
void  SearchbyNum(long num[], char name[][MAX_LEN], float score[], int n)           /*选项7 按学号查询学生排名及其考试成绩*/
{long se;int i, t=0;printf("Input the number you want to search:\n");scanf("%ld", &se);for(i=0; i<n; i++){if(num[i]==se){printf("%ld\t%s\t%.0f\n", num[i], name[i], score[i]);t=1;}}if(t==0){printf("Not found!\n");}
}
void  SearchbyName(long num[], char name[][MAX_LEN], float score[], int n)          /*选项8 按姓名查询学生排名及其考试成绩*/
{char se[MAX_LEN];int i, t=0;printf("Input the name you want to search:\n");scanf("%s", se);for(i=0; i<n; i++){if(strcmp(se, name[i])==0){printf("%ld\t%s\t%.0f\n", num[i], name[i], score[i]);t=1;}}if(t==0){printf("Not found!\n");}
}
void  StatisticAnalysis(float score[], int n)           /*选项9 输出百分比*/
{int d1, d2, d3, d4, d5, d6, i;for(i=0, d1=d2=d3=d4=d5=d6=0; i<n; i++){if(score[i]<60){d1++;}else if(score[i]<70){d2++;}else if(score[i]<80){d3++;}else if(score[i]<90){d4++;}else if(score[i]<100){d5++;}else{d6++;}}printf("<60\t%d\t%.2f%%\n", d1, 100*(float)d1/n);printf("%d-%d\t%d\t%.2f%%\n", 60, 69, d2, 100*(float)d2/n);            /*这里按题意应该用循环的,但是用了有点麻烦*/printf("%d-%d\t%d\t%.2f%%\n", 70, 79, d3, 100*(float)d3/n);printf("%d-%d\t%d\t%.2f%%\n", 80, 89, d4, 100*(float)d4/n);printf("%d-%d\t%d\t%.2f%%\n", 90, 99, d5, 100*(float)d5/n);printf("%d\t%d\t%.2f%%\n", 100, d6, 100*(float)d6/n);
}
void  PrintScore(long num[], char name[][MAX_LEN], float score[], int n)            /*输出每个学生的学号、姓名和考试成绩*/
{int i;for(i=0; i<n; i++){printf("%ld\t%s\t%.0f\n", num[i], name[i], score[i]);}
}

哈工大慕课 学生成绩管理系统V3.0相关推荐

  1. 哈工大慕课 学生成绩管理系统V1.0~5.0

    文章目录 学生成绩管理系统V1.0 学生成绩管理系统V2.0 学生成绩管理系统V3.0 学生成绩管理系统V4.0 学生成绩管理系统V5.0 本文提供测试数据哦~ 运行时请将数据粘贴到输入框中. 由于自 ...

  2. 第11章实验1:学生成绩管理系统V4.0

    第11章实验1:学生成绩管理系统V4.0 某班有最多不超过30人(具体人数由键盘输入)参加期末考试,最多不超过6门(具体门数由键盘输入).参考学生成绩管理系统V3.0,用二维数组作函数参数编程实现如下 ...

  3. 第11章实验1:学生成绩管理系统V4.0(C语言)

    第11章实验1:学生成绩管理系统V4.0 (前方空降提示:由于题目很长很长很长,代码在最后,翻到底才有哦.) 某班有最多不超过30人(具体人数由键盘输入)参加期末考试,最多不超过6门(具体门数由键盘输 ...

  4. 第12章实验1:学生成绩管理系统V5.0(c语言)

    第12章实验1:学生成绩管理系统V5.0 某班有最多不超过30人(具体人数由键盘输入)参加期末考试,最多不超过6门(具体门数由键盘输入).参考学生成绩管理系统V4.0,定义结构体类型,用结构体数组作函 ...

  5. 第12章实验1:学生成绩管理系统V5.0

    第12章实验1:学生成绩管理系统V5.0 第12章实验1:学生成绩管理系统V5.0 某班有最多不超过30人(具体人数由键盘输入)参加期末考试,最多不超过6门(具体门数由键盘输入).参考学生成绩管理系统 ...

  6. 第8章实验1:学生成绩管理系统V1.0

    第8章实验1:学生成绩管理系统V1.0 某班有最多不超过30人(具体人数由键盘输入)参加某门课程的考试,用一维数组作函数参数编程实现如下学生成绩管理: (1)录入每个学生的学号和考试成绩: (2)计算 ...

  7. 学生成绩信息管理系统c语言,C语言写的学生成绩管理系统V4.0

    学生成绩管理系统V4.0 学生成绩管理系统软件主要适用于成绩管理!这款软件具有成绩输入.各班成绩汇总分析.成绩打印.成绩综合排名等一系列功能.这款软件完全根据学校平常的学生成绩管理办法研发出来.运用先 ...

  8. Python实现学生信息管理系统V3.0(GUI界面)

    关于"学生信息管理系统"的基本思路和详细过程,请看V1.0版本: Python实现学生信息管理系统V1.0_︶ㄣ释然的博客-CSDN博客本文是关于学生信息管理系统的简易版以及具体内 ...

  9. 大学C语言系统作业,c语言大作业_学生成绩管理系统v5.0.doc

    Word格式 完美整理 //成绩管理系统v1.0 #include #include #include #define N 30 #define M 6 typedef struct student ...

最新文章

  1. 产品设计体会(1011)少做就是多做
  2. Eclipse中JVM内存设置
  3. linux 后台计算,科学网-如何在Linux中做批处理和后台计算-张彦的博文
  4. C语言100例01 PHP版(练习)
  5. PS教程第十三课:是时候开始战斗了
  6. centos linux怎么安装mysql_CentOS-Linux系统下安装MySQL
  7. Dropout抑制过拟合与超参数选择
  8. 大数据技术平台主要分为哪几类
  9. CAS(Central Authentication Service)——windows上简单搭建及測试
  10. Fluentd: Open Source Log Management
  11. Atitit. camel分词器 分词引擎 camel拆分 的实现设计
  12. 最新 PMP 考试真题概要及答案分析(中文版)(1)
  13. Microsoft DirectX组件v11.0完整版更新啦
  14. 大写汉字转阿拉伯数字c语言,把中文汉字大写数字 转换成 阿拉伯数字
  15. ICCV、ECCV、CVPR三大国际会议
  16. 当当网复工员工确诊,66人集中隔离,负责人被约谈
  17. 计算机专业mac好用吗,苹果笔记本电脑系统好用吗_苹果笔记本电脑系统好用不好用-win7之家...
  18. 中国商贸物流行业运行状况分析及投资规模预测报告2021-2027年
  19. typedef的用法简介
  20. debian安装和基本使用

热门文章

  1. RabbitMQ+PHP演示实例二
  2. 网站推荐:Google音乐搜索引擎
  3. 《百闻牌》体验设计之道——和崽崽在妖怪世界打牌(UI篇)
  4. python爬取51job的示例
  5. excel的主要功能_晨曦计价软件新增的这项功能,你肯定不知道!
  6. seata+eureka使用
  7. 2013百度安卓巴士轻应用4城市巡展沙龙,免费报名啦
  8. 玩战塔英雄不显示服务器,战塔英雄手游画质怎么设置?画质设置方法图文介绍...
  9. 刘关张三结义(第七次作业)
  10. 李飞飞计算机视觉课CS231n第一天