首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面的程序是找出两个正整数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
20
问题
下面的程序是找出两个正整数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://jikaoti.com/ti/T860FFFM
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
在窗体中添加一个命令按钮,并编写如下程序:PrivateSubCommand1_CliCk()X=1∶Y=2∶Z=3X=Y∶Y=Z∶Z=XPrintZEnd
假设有程序代码如下:Form1.Caption="Open",这里Form1、Caption和Open分别代表______。
数据库设计包括两个方面的设计内容,它们是______。
创建一个窗体,在该窗体中建立两个按钮,分别命名为Command1和Command2。下列程序代码用于实现以下功能:单击命令按钮Command1后,按钮Command1变为不可用,而Cmmnand2设置为可用。请填空。PrivateSubCommand
结构化程序设计原则和方法中要求对语言中所没有的控制结构,应该采用【】的方法来模拟。
下列程序段的执行结果为______。PrivateSubCommand1_Click()n=0Fora=1To20Forb=1To20For
执行以下程序段,如果在对话框中输入8,输出结果是"Hello"的是______。
下面一段程序的功能是,单击窗体弹出对话框。在对话框中输入一个文件名,窗体中输出该文件名的文件号。请填空。PrivateSubForm_click()filename=InputSox(“请输入文件名”)Filecode=Openfi
随机试题
撰写市场研究报告应该注意的问题不包括()
Wemust______earlyinthemorningsoastocatchthefirsttrain.
稀释式自身输血是指在麻醉成功后手术开始前,采集患者一定数量的血液,同时输注一定数量的晶体和胶体溶液以补充有效循环容量且维持其正常稳定,使血液稀释,并在患者失血后回输其先前采集的血液。适用于为避免前负荷过大造成急性左心衰,在麻醉前采集患者全血的自身输血方
从投资者角度看,风险分为两类:市场风险和公司特有风险,下列属于公司特有风险的有:()。
设备制造前的进度控制内容包括( )。
某沿海城市道路改建工程4标段,道路正东西走向,全长973.5m,车行道宽度15m,两边人行道各3m,与道路中心线平行且向北,需新建DN800mm雨水管道973m。新建路面结构为150mm厚砾石砂垫层,350mm厚二灰混合料基层,80mm厚中粒式沥青混凝土,
下列文化现象是在维新变法的思想启蒙作用下发生的有()。①史学革命②诗界革命③清末小说繁荣④京剧形成
图中的“X”等于()。根据材料,以下说法正确的是()。
被告人:刘某,男,30岁。l995年6月因犯故意伤害罪被判处有期徒刑3年,1998年6月刑满释放。景某,男,25岁。1995年7月因盗窃被劳动教养3年,1998年7月解除劳动教养,2000年11月28日因本案被逮捕。20009月间,被告人刘某找到被告人
Intheearly1450’sculturalchangeinEuropefueledagrowingneedfortherapidandcheapproductionofwhitendocuments.Befo
最新回复
(
0
)