首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
设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
2020-06-30
21
问题
设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/VIHp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
请根据以下各小题的要求设计VisualBasic应用程序(包括界面和代码)。(1)在名称为Form1、标题为“电影制作”的窗体上画1个名称为Cmb1、初始内容为空的下拉式组合框(可以输入文本)。下拉列表中有“音频效果”、“视频效果”和“视频过渡
在考生文件夹下有一个工程文件sjt5.vbp,已给出了部分控件和部分程序。程序运行时,请在窗体上画三个标签,其名称分别为Label1、Label2和Label3,标题分别为“姓名”、“电话号码”和“邮政编码”。再画三个文本框,其名称分别为Text1、Tex
在考生文件夹下有一个工程文件sjl5.vbp,窗体上有2个标题分别是“读数据”和“查找质数”的命令按钮。请画1个名称为Text1、初始值为空的文本框,该文本框允许显示多行内容,且有垂直滚动条,如图3-36所示。程序功能:(1)考生文件
有三个关系R、S和T如下:由关系R和S通过运算得到关系T,则所使用的运算为()。
设窗体上有2个文本框Text1和Text2,并有下面的事件过程:DimnPrivateSubText1_KeyPress(KeyAsciiAsInteger) If"A"
设有如下函数:FunctionDelSpace(chAsString)AsInteger Dimn%,st$,c$ st="" n=0 Fork=1ToLen(ch) c=Mid(ch,k,1) I
在软件开发中,需求分析阶段产生的主要文档是()。
以下关于VB文件的叙述中,正确的是
下列关于水平滚动条的叙述中,错误的是()。
随机试题
马斯洛需要层次论中的最高层次是()
痛风的治疗肝豆状核变性的治疗
易致肝风内动的邪气是
月末存在未达账项时,企业可以动用的银行存款数额是( )。
关于政府补助的计量,下列说法中正确的有()。
有50张3元邮票和30张5元邮票,用这些邮票能组成______种不同的邮资.
结合实际简述学习动机的激发。
计算曲面积分,其中∑是曲线绕z轴旋转一周所得到的曲面,取外侧.
微分方程满足初始条件y|x=2=1的特解是________.
【21】【36】
最新回复
(
0
)