首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
请编写一个函数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
20
问题
请编写一个函数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://jikaoti.com/ti/iFkiFFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
论述1927—1949年中共土改各阶段政策文件及改革内容和影响。(复旦大学2015年历史学综合真题)
试析晚清学校与选举制度的演变并论其影响。(北京大学2000年中国通史真题)
要求被试在识记材料后,尽量将识记的全部项目再现出来,以此确定感觉记忆的保存量,称为()。
一位教育学教师让每个学生报告他们用于准备考试的时间和考试时答错的题目数:忽略样本容量的问题,解释两种相关系数的大小为何有差异,在上述数据中,你认为哪种更准确地反映了数据的关系?
一位教育学教师让每个学生报告他们用于准备考试的时间和考试时答错的题目数:计算用于准备考试的时间和考试时答错的题目数之间的等级相关系数。
夸美纽斯主张国家既对教育具有不可推卸的责任,也有管理教育的最高权力。下列对夸美纽斯此方面的主张表述错误的是
日本近代教育史上的第一个新学制是1872年颁布的(),它规定全国实行中央集权式的大学区制。
“要尽量多地要求一个人,也要尽可能多地尊重一个人”所体现的德育原则是()
随机试题
A.生血不足或失血过多B.久病耗血或年老精亏C.产后恶露日久不净D.热病后期,阴津亏损血燥生风的病因是
线性方程式是
急性脱髓鞘性多发性神经炎病情危重的表现是
市场需求不太明确,不确定风险高,而且目前尚看不到什么明显的利润,商品的夭折率很高,这样的市场机会属于()市场机会。
在风景名胜区内进行开山、采石、开矿等破坏景观、植被、地形地貌的活动的,由风景名胜区管理机构责令停止违法行为、恢复原状或者限期拆除,没收违法所得,并处()的罚款。
随着房地产市场竞争的加剧,传统的平面图、沙盘、样板房等已经远远不能满足消费者的需要。策划者敏锐地把握市场动向,果断启用最新的技术,使购房者无须亲临实地,也可以在三维场景中观赏到优美的小区环境、居室空间,甚至还可以透过窗户欣赏户外的风景。这里所说的“启用最新
经营性长期负债
甲本想使用毒药杀害张三,但因为误认而错用了白糖,甲的行为属于()
MostworthwhilecareersrequiresomekindofspecializedtrainingIdeally,therefore,thechoiceofan【21】______shouldbe
It’sa(47)______oftenrequestedinlonelyheartsadsandscientistshavenowshownthatagoodsenseofhumoris(48)______fo
最新回复
(
0
)