首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
m个人的成绩存放在score数组中,请编写函数fun,它的功能是:将低于平均分的人数作为函数值返回,将低于平均分的分数放在below所指的数组中。 例如,当score数组中的数据为10、20、30、40、50、60、70、80、90时,函数返回的人
m个人的成绩存放在score数组中,请编写函数fun,它的功能是:将低于平均分的人数作为函数值返回,将低于平均分的分数放在below所指的数组中。 例如,当score数组中的数据为10、20、30、40、50、60、70、80、90时,函数返回的人
admin
2016-12-06
41
问题
m个人的成绩存放在score数组中,请编写函数fun,它的功能是:将低于平均分的人数作为函数值返回,将低于平均分的分数放在below所指的数组中。
例如,当score数组中的数据为10、20、30、40、50、60、70、80、90时,函数返回的人数应该是4,below中的数据应为10、20、30、40。
注意:部分源程序在文件PROG1.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
1 #include<conio.h>
2 #include<stdio.h>
3 #include<string.h>
4 #include<stdlib.h>
5 int fun(int score[],int m,int below[])
6 {
7
8 }
9 void main()
10 {
11 FILE*wf;
12 int i,n,below[9];
13 int score[9]={10,2 0,30,40,50,60,70,80,90};
14 system(’’CLS’’);
15 n=fun(sCOEe,9,below);
16 printf(’’\nBelow the average score are:’’);
17 for(i=0 ; i
18 printf(’’%d’’,below
);
19 /*****************/
20 wf=fopen(’’out.dat’’,’’w’’);
21 for(i=0;i
22 fprintf(wf,’’%d’’,below
);
23 fclose(wf);
24 /*****************/
25 }
选项
答案
1 int fun(int score[],int m,int be-low[]) 2 { 3 int i,j=0 ; 4 float av=0.0; 5 for(i=0 ; i
解析
要计算低于平均分的人数,首先应该求出平均分,然后通过for循环语句和if条件语句找出低于平均分的分数。该题第1个循环的作用是求出平均分av,第2个循环的作用是找出低于平均分的成绩记录并存入below数组中。
转载请注明原文地址:https://kaotiyun.com/show/QNDp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下程序运行后的输出结果是______。main(){inta=1,b=2,c=3;if(c=a)printf("%d\n",c);elseprintf("%d\n",b);}
若有以下程序段:intm=0,n=0;charc=’a’;scanf("%d%c%d",&m,&c,&n);printf("%d,%c,%d\n",m,c,n);若从键盘上输入:10A10<回车>,则输出结果是__
为了使模块尽可能独立,要求______。
以下程序中,函数SumColumMin的功能是:求出M行N列二维数组每列元素中的最小值,并计算它们的和值。和值通过形参传回主函数输出。请填空。#defineM2#defineN4
以下程序的功能是将字符串s中的数字字符放人d数组中,最后输出d中的字符串。例如,输入字符串abc123edf456gh,执行程序后输出123456。请填空。#include<stdio.h>#inclu
有以下定义:#include<stdio.h>chara[l0],*b=a;不能给a数组输入字符串的语句是______。
有以下程序:main(){inta[3][3],*p,i;p=&a[0][0];for(i=0;i<9;i++)p[i]=i;for(i=0;i<3;i++)printf("%d",a[1][
设有定义:intA,*pA=&A;,以下scanf语句中能正确为变量A读入数据的是______。
下列程序的功能是对输入的一行字符中的数字字符的字面值累加,输出此累加和,请填空。#include<stdio.h>#include<ctype.h>main(){charc;
以下程序段中与语句k=a>b?(b>c?1:0):0;功能等价的是______。
随机试题
为了从拉伸截面线串移去对象,当你选择对象时你将需要在按下MB1同时按下:
输出小管和附睾管的上皮均为假复层纤毛柱状上皮。
环糊精包合物制备可采用脂质体制备可采用
甲、乙订立合同,买卖大米50袋、面粉50袋、大豆50袋。后甲交付后,乙发现50袋面粉乙明显受潮霉变,下列说法错误的是()
银行经营管理实践中所探索的目标是在不同经济环境下,探寻影响商业银行价值的主要因素,进而起到改善商业银行在不同历史时期经营管理的作用。()
《学记》提出“学不躐等”“杂施而不孙,则坏乱而不修”,揭示教学中应贯彻()。
领导信箱回应不及时、反映问题得不到解决,请分析原因及解决对策。
世界是丰富多彩的,在社会主义现代化建设新时期,所有制结构的多样性,决定了指导思想必然是多元的。
NoticeofRegularWindowCleaningDate:May10To:AllEmployeesAlloftheoutsidewindowswillbewashedandcleanedduringt
Nowlistentopartofalectureinabiologyclass.Theprofessorisdiscussingthetypesofhabitatsforwildlifefoundinciti
最新回复
(
0
)