第十八周学生成绩处理
来源:互联网 发布:淘宝苹果id解锁靠谱吗 编辑:程序博客网 时间:2024/04/29 16:20
/*******************************************************Copyright (c) 2016,烟台大学计算机学院All rights reserved.作者:张明明完成日期:2016年12月30日版本号:v1.0功能描述:输入n个学生成绩,算出其中最高分,最低分,平均分,标准偏差,并求出最高分,最低分同学的个数和学号;输入参数:num-学生个数 s-储存成绩的数组返回参数:get_max_score-学生成绩中最高分 get_max_score—学生成绩中最低分 get_avg_score-学生的平均成绩值 get_stdev_score-学生成绩的标准的偏差 count-学生成绩的最高分或最低分的人数 output_index-输出学生成绩最高分和最低分的学号其他说明:无*******************************************************/#include <stdio.h>#include <stdlib.h>#include<math.h>void input_score(int s[], int n); //将小组中n名同学的成绩输入数组sint get_max_score(int s[], int n); //返回数组s中n名同学的最高成绩值int get_min_score(int s[], int n); //返回数组s中n名同学的最低成绩值double get_avg_score(int s[], int n); //返回数组s中n名同学的平均成绩值double get_stdev_score(int s[], int n); //返回数组s中n名同学成绩值的标准偏差int count(int x, int s[], int n); //返回在数组s中n名同学中有多少人得x分(实参给出最高/低时,可以求最高/低成绩的人数)void output_index(int x, int s[], int n); //在函数中输出数组s中n名同学中得x分的学号(下标)double avg;int main( ){ int score[50]; //将score设为局部变量,通过数组名作函数参数,传递数组首地址,在函数中操作数组 int num; //小组人数也设为局部变量,将作为函数的实际参数 int max_score,min_score; printf("小组共有多少名同学? "); scanf("%d", &num); printf("请输入学生成绩:\n"); input_score(score, num); //要求成绩在0-100之间 max_score=get_max_score(score, num); printf("最高成绩为:%d,共有 %d 人\n", max_score, count(max_score, score, num )); min_score=get_min_score(score, num); printf("最低成绩为:%d,共有 %d 人\n", min_score, count(min_score,score, num )); printf("平均成绩为:%.2f\n", get_avg_score(score, num)); printf("标准偏差为:%.2f\n",get_stdev_score(score, num)); printf("获最高成绩的学生(学号)有:"); output_index(max_score,score, num); printf("\n获最低成绩的学生(学号)有:"); output_index(min_score,score, num); printf("\n"); return 0;}void input_score(int s[], int n){ int i; for(i=0;i<n;i++) { do { printf("第%d位学生的成绩为:",i); scanf("%d",&s[i]); }while(s[i]>100||s[i]<0); } return ;}int get_max_score(int s[], int n){ int i,max=s[0]; for(i=0;i<n;i++) { if(s[i]>max) max=s[i]; } return max;}int get_min_score(int s[], int n){ int i,min=s[0]; for(i=0;i<n;i++) { if(s[i]<min) min=s[i]; } return min;}int count(int x, int s[], int n){ int i,sum=0; for(i=0;i<n;i++) { if(s[i]==x) sum++; } return sum;}double get_avg_score(int s[], int n){ int i,sum=0; for(i=0;i<n;i++) sum+=s[i]; avg=sum/n; return avg;}double get_stdev_score(int s[], int n){ int i,sum=0; double s1=0; for(i=0;i<n;i++) s1+=((s[i]-avg)*(s[i]-avg)); return sqrt(s1/(n-1));}void output_index(int x, int s[], int n){ int i=0; while(s[i]!='\0') { if(s[i]==x) printf("%d\t",i); i++; } return 0;}
0 0
- 第十八周学生成绩处理
- 第十八周--学生成绩管理
- 第十七周实验报告--学生成绩处理
- 第十六周--用二进制文件处理学生成绩
- 第十三周 Oj 学生成绩的处理
- 第13周 oj 学生成绩处理
- 第十三周—学生成绩处理
- 第十三周项目一学生成绩处理
- 第十三周oj实践学生成绩处理
- 第十三周OJ(1)学生成绩处理
- 十三周OJ1学生成绩的处理
- 第十三周学生成绩的处理
- 十六周—学生成绩处理
- 第16周 学生成绩处理1.0
- 第十六周项目二学生成绩处理
- 第十六周项目--学生成绩处理
- 第十六周 项目2---学生成绩处理
- 第16周 学生成绩处理2.0
- java实现二叉树基本操作
- 227. Basic Calculator II**
- 如何处理单行文本和多行文本溢出
- 强大的动态绑定
- Spring Web Flow 入门demo(二)与业务结合 附源码
- 第十八周学生成绩处理
- 1005. 继续(3n+1)猜想 (25)
- tomcat-redis-session-manager小坑记录
- 支持向量机从基础到前沿(二:SVM入门之欲练此功)
- Windows U盘文件分类折叠
- HBase协处理器
- python3 pickle(序列化)
- C语言期末课程设计3.电子词典
- Spring Web Flow 入门demo(三)嵌套流程与业务结合 附源码