首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面的程序是找出两个正整数a和b,使得a<b、a+ b=99、a和b的最大公约数是3的倍数,并统计满足条件数对的个数。 Option Explicit Dim a As Integer, b As Integer, n As Integer, c As I
下面的程序是找出两个正整数a和b,使得a<b、a+ b=99、a和b的最大公约数是3的倍数,并统计满足条件数对的个数。 Option Explicit Dim a As Integer, b As Integer, n As Integer, c As I
admin
2013-04-11
18
问题
下面的程序是找出两个正整数a和b,使得a<b、a+ b=99、a和b的最大公约数是3的倍数,并统计满足条件数对的个数。
Option Explicit
Dim a As Integer, b As Integer, n As Integer, c As Integer
Private Function Gcd (ByVal a As Integer, Byval b As Integer) As Integer
do
c=a Mod b: a=b=c
Loop【 】
Gcd=a
End Function
Private Sub form_ Click()
n=0
for a= 1 To 49
b=【 】
c= Gcd (a, b)
if c Mod 3= 0 then
【 】
Print a, b, c
End if
Next a
Print n
End Sub
选项
答案
until c=0或while c<>0,99-a,n=n+1
解析
由求最大公约数的算法可知,当余数c为零时,a为a和b的最大公约数。因条件给定:“a+ b=99”,所以“b=99-a”。n为累计数。
转载请注明原文地址:https://kaotiyun.com/show/o2Qp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
在窗体中添加一个命令按钮,并编写如下程序:PrivateSubCommand1_CliCk()X=1∶Y=2∶Z=3X=Y∶Y=Z∶Z=XPrintZEnd
应用程序窗体的名称属性为Frm1,窗体上有一个命令按钮,其名称属性为Cmd1,用户单击窗体和单击该命令按钮所使用的事件过程名分别是:______。
结构化程序设计原则和方法中要求对语言中所没有的控制结构,应该采用【】的方法来模拟。
下列程序段的执行结果为______。PrivateSubCommand1_Click()n=0Fora=1To20Forb=1To20For
执行以下程序段,如果在对话框中输入8,输出结果是"Hello"的是______。
下面一段程序的功能是,单击窗体弹出对话框。在对话框中输入一个文件名,窗体中输出该文件名的文件号。请填空。PrivateSubForm_click()filename=InputSox(“请输入文件名”)Filecode=Openfi
随机试题
阅读下列材料,回答问题。小学生小亮很想学好数学,但数学成绩一直很差,多方面努力都没有起色。近期,班主任发现小亮上课变得不听讲,还时不时扰乱课堂秩序,不完成家庭作业,数学老师催促也不见效,之后连续几次数学考试都是班上最后一名。班主任通过与小亮谈话了
庆典活动要达到与众不同需要做到__________、__________、__________。
透明管型明显增多见于
患者,女,67岁。腹水1个月伴消瘦、乏力、腹胀。腹水病理检查找到癌细胞,血清CEA(+),大便检查有许多红细胞、白细胞及脓细胞,细菌培养无痢疾杆菌,用抗生素治疗无效。B超检查为双侧卵巢占位性病变。确诊最重要的检查是
下列关于风湿性疾病病理特点中哪项说法有误()
治疗重肌无力宜选用()。
产后恶露不绝指血性恶露持续()。
土地权利中,所谓支配是指()。
汇入银行对汇入的采购款项,以()名义开立采购账户。
支付结算是指单位在社会经济活动中使用票据、银行卡和汇兑、托收承付、委托收款等结算方式进行货币给付及其资金清算的行为。个人在社会经济活动中使用票据、银行卡等方式进行资金清算的行为不属于支付结算的范畴。()
最新回复
(
0
)