首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请编写一个函数fun(int score [][3],int num),该函数返回有一门成绩以上课程成绩在85分以上,其余课程成绩不低于70分的人数。数组score按行存放num名考生各自的三门期末考试成绩。 注意:部分源程序已存在文件test31_
请编写一个函数fun(int score [][3],int num),该函数返回有一门成绩以上课程成绩在85分以上,其余课程成绩不低于70分的人数。数组score按行存放num名考生各自的三门期末考试成绩。 注意:部分源程序已存在文件test31_
admin
2010-02-08
21
问题
请编写一个函数fun(int score [][3],int num),该函数返回有一门成绩以上课程成绩在85分以上,其余课程成绩不低于70分的人数。数组score按行存放num名考生各自的三门期末考试成绩。
注意:部分源程序已存在文件test31_2.cpp中。
请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。
程序输出结果如下:
3
文件test31_2.cpp清单如下:
#include <iostream.h>
int fun(int score[] [3],int num)
{
}
void main ( )
{
int score[4] [3]={{70,89,92},{70,76,93},(80,86,98},{65,73,45});
cout<<fun(score,4)<<end1;
}
选项
答案
int fun(int score[] [3],int num) { int total=0; int flag=0; for (int i=O;i { for(int j=O;j<3;j++) { if (score[i] [j]<70) { flag=-1; j=3; } else if(score[i] [j]>=85) flag=1; } if (flag==1) total=total+1; flag=0; } return total; }
解析
本题主要考查考生对数组和基本控制语句的熟练程度。对于4*3的二维数组score,其下标的范围是从(0,0)到(3,2),这一点是需要特别注意的。另外程序中通过设置,临时变量flag来标志每个人的分数信息,以得到所要统计的人数的方法是需要在编程中灵活掌握的。
转载请注明原文地址:https://kaotiyun.com/show/D7ID777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
斯皮尔曼等级相关适用于两列具有哪种性质的测量数据,或总体为非正态的等距、等比数据?()
一位教育学教师让每个学生报告他们用于准备考试的时间和考试时答错的题目数:忽略样本容量的问题,解释两种相关系数的大小为何有差异,在上述数据中,你认为哪种更准确地反映了数据的关系?
福禄贝尔建立了一个以活动与游戏为主要特征的幼儿园课程体系,其依据不包括
下列作品不是苏霍姆林斯基的是
“要尽量多地要求一个人,也要尽可能多地尊重一个人”所体现的德育原则是()
认为学校教育的功能就是再生产出占主导地位的社会政治意识形态、文化关系和经济结构的是
关于终身教育,下列说法错误的是
生物起源说和心理起源说的根本错误在于否认了教育的
随机试题
患者,女,25岁。右下牙合后牙及右面部肿痛3周。检查见右面部肿胀以下牙合支及下牙合角为中心,局部软组织变硬,有凹陷性水肿,开口度1cm如需切开引流,应注意保护
患者,男,72岁。喘咳,咳痰清稀,面浮肢肿,脘痞,纳差,尿少,怕冷,口唇青紫,舌暗,苔白滑,脉沉细。此病可诊断
()主要负责现金和银行存款的管理。
等腰三角形、直角三角形和等边三角形都是三角形的()。
对于公安工作的含义理解正确的是()。
简述维果茨基的文化历史发展理论。
有以下程序:#includemain(){FILE*fp;inta[10]={1,2,3,0,0},i;fp=fopen("d2.dat","wb");fwrite(a,sizeof(int),5,fp);fwrite
有以下程序intfun(intn){ifln=1)return1;elseretum(n+fun(n-1));}main(){intx;scanf(’’%d’’,&x);x=fun(x);printf(’’%d\n’’,x);}
有如下类声明:classFin{public:Fin();//①Fin*pf;//②Finf;//③Fin&p;//④
__________(对我们不好)toreadinastronglight.
最新回复
(
0
)