首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
设a、b都是自然数,为求a除以b的余数,某人编写了以下函数: Function fun(a As Integer,b As Integer) While a>b a=a-b Wend fun=a End Function 在调试时发现函数是错
设a、b都是自然数,为求a除以b的余数,某人编写了以下函数: Function fun(a As Integer,b As Integer) While a>b a=a-b Wend fun=a End Function 在调试时发现函数是错
admin
2019-03-14
23
问题
设a、b都是自然数,为求a除以b的余数,某人编写了以下函数:
Function fun(a As Integer,b As Integer)
While a>b
a=a-b
Wend
fun=a
End Function
在调试时发现函数是错误的。为使函数能产生正确的返回值,应做的修改是( )。
选项
A、把a=a-b改为a=b-a
B、把 a=a-b 改为a=a\b
C、把While a>b 改为While a
D、把While a>b 改为While a>=b
答案
D
解析
程序中没有考虑余数为0的情况,即,条件中应该有a=b,则a=a-b,这样才能正确得到余数0。因此程序中应该修改While的条件a>b为a>=b。
转载请注明原文地址:https://kaotiyun.com/show/AOFp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
设有表达式:A=IIf(x>y,"go","back")。以下与该表达式具有相同功能的语句是
VB工程文件的扩展名是
设有以下程序代码:PrivateSubCommand1_Click()DimxAsString,yAsIntegerx="考试"y=1procx,yPrint"第";y;
以下操作中,不能改变窗体大小的是
在窗体上画一个名称为Text1的文本框和一个名称为Commandl的命令按钮,然后编写如下事件过程:PrivateSubCommandl_Click()DimiAsInteger,nAsIntegerFori=
设a=2,b=3,c=4,d=5,表达式Nota
下列选项中不属于软件生命周期开发阶段任务的是
窗体上有1个名为Listl的列表框,其中已经输入了若干个项目(如图3所示);还有2个文本框,名称分别为Text1、Text2,1个名称为Command1的命令按钮,并有以下程序。PrivateSubCommand1Click()
在考生文件夹下有一个工程文件sjt4.vbp。窗体上有名称为Label1的标签和名称为Timer1的计时器控件。该程序的功能是在名称为Label1的标签中循环显示不同的字符串。程序开始运行,在标签中显示“第一项”(如图3-114所示),且每隔1秒钟依次显示
随机试题
工作介质为气体的管道,一般应用不带油的压缩空气或氮气进行吹扫。()
对关键字序列(6,1,4,3,7,2,8,5)进行快速排序时,以第1个元素为基准的一次划分的结果为()
河北某尼龙企业将其10个不同的尼龙公司重组为一个企业之后,面临的首要问题就是如何对新企业进行竞争性定位。对其竞争对手的客户所进行的初步调查显示:在客户偏好方面,该企业只排第三位,落后于处于行业领先地位的其他两家企业。调查还显示:客户对尼龙供应商的服务均不满
商业循环实际上表示的是______反复出现的上升与下降的交替运动。()
设随机变量X的分布函数为则概率密度fX(x)为________.
A.被称为完全固定桥B.一端的固位体为同定连接,另一端的同位体为活动连接的固定桥C.仅一端有固位体,桥体与固位体之间为固定连接的固定桥D.以各种骨内种植体作为固定桥的支持和固位端制成的固定桥E.可以自行摘戴的固定桥种植固定桥()
受行政处分的是()。
设备的寿命可分为()。
劳动力总量大、成本低,曾是“中国制造的比较优势”,但随着人口结构的变化,这一优势正在不断消减。按照联合国的标准,65岁以上的人口比率超过总人口的7%,就被称为老龄化社会;超过14%,就是老龄社会。中国实际上在2001年就已经进入了老龄化社会。近年来东南沿海
在标准正态分布曲线下,正负1个标准差范围内的面积占曲线下总面积的()
最新回复
(
0
)