首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
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-08-16
29
问题
m个人的成绩存放在score数组中,请编写函数fun,它的功能是:将低于平均分的人数作为函数值返回,将低于平均分的分数放在below所指的数组中。
例如,当score数组中的数据为10、20、30、40、50、60、70、80、90时,函数返回的人数应该是4,below中的数据应为10、20、30、40。
注意:部分源程序在文件PROGl.C中。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
试题程序:
#include
#include
#include
#include
int fun(2nt score[],2nt m,2nt
below[])
{
}
void main()
{
FILE*wf;
int i,n,below[9];
int score[9]={10,20,30,40,50,60,70,80,90};
system("CLS");
n=fun(score,9,below);
printf("\nBelow the average
score are:");
for(i=0;i
printf("%d",below
);
/***********************/
wf=fopen("out.dat","w");
for(i=0;i
fprintf(wf,"%d",below
);
fclose(wf);
/***********************/
}
选项
答案
int fun(int score[],int m,int below[]) { int i,j=0; float av=0.0; for(i=0;i
解析
要计算低于平均分的人数,首先应该求出平均分,然后通过for循环语句和if条件语句找出低于平均分的分数。该题第1个循环的作用是求出平均分av,第2个循环的作用是找出低于平均分的成绩记录并存入below数组中。
转载请注明原文地址:https://kaotiyun.com/show/j4Np777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在程序设计阶段应该采取【】和逐步求精的方法,把一个模块的功能逐步分解,细化为一系列具体的步骤,进而用某种程序设计语言写成程序。
在进行了任何C++流的操作后,都可以用C++流的有关成员函数检测流的状态,其中只能用于检测刚进行的操作是否失败函数名是()。
假定MyClass为一个类,那么下列的函数说明中,()为该类的析构函数。
在C++语言中,对函数参数默认值描述正确的是()。
以下程序的功能是:按顺序读入10名学生4门课程的成绩,计算出每个学生的平均分数并输出,程序如下:#include<iostream>usingnamespacestd;intmain(){i
随机试题
WhatdidHelen’semployersgiveherformalfeedbackon?
中心型肺癌与肺门淋巴结结核鉴别,最好的手段是
急性牙髓炎主要表现是剧烈的疼痛,其疼痛特点下列哪项是错误的
患者女性40岁,情绪低落、快感丧失、兴趣丧失和精力丧失,似乎充满了无助和绝望,体会不到生活的乐趣。长期口服阿米替林,175mg,1次/日。因家中变故,惊恐发作加重,每周发作4~5次,前来就诊。诊断:抑郁症。医嘱如下。该患者使用地西泮的作用是(
47号元素Ag的基态价层电子结构为4d105s1,它在周期表中的位置是:
东南沿海某市拟建西北绕城高公路工程有主线和一条连接线组成。主线全长57.55km,按照双向六车道高速公路标准建设,设计行车速度100km/h,路基宽度33.5m。主线起点(K0+000)接城西已建高速互通,在城区外围向东北方向展线,以桥梁形式(K26+12
按利率的制定可将利率划分为:()。
设a1,a2,…,as均为n维列向量,A是m×n矩阵,则下列选项正确的是().
OurculturehascausedmostAmericanstoassumenotonlythatourlanguageisuniversalbutthatthegesturesweuseareunderst
Forthispart,youareallowedthirtyminuteswwriteacompositiononthetopic"ReadingSelectivelyorExtensively".Youshoul
最新回复
(
0
)