首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面的程序是找出两个正整数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
2010-09-11
29
问题
下面的程序是找出两个正整数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/cEg0FFFM
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
当要将一个文本文件当作一个数据库访问时,读完一个记录后,跳到另一个记录,它们在文件的不同地方时,一般使用( )类访问。
下面( )部分不属于变量的组成部分。
下列选项中不属于软件生命周期开发阶段任务的是( )。
下列叙述中,正确的是______。
负责数据库中查询操作的数据库语言是______。A)数据定义语言B)数据管理语言C)数据操纵语言D)数据控制语言
为了支持压栈线程与弹栈线程之间的交互与同步,在下画线处依次填入的语句是publicclassIntStack{ privateintidx=0; privateint[]data=newint[8]; publ
下面Java语句从指定的网址读取HTML文件,在下画线处应填上的选项是Readerin=new______(newURL(urlString).openStrream());
下列适配器类中不属于事件适配器的是
数据库设计包括概念设计、______和物理设计。
规范化理论中消除其中多余的数据相关性是靠分解()来实现。
随机试题
A.紧急避孕药B.短期避孕药C.长效避孕药D.阴茎套E.安全期避孕遭到性暴力首选
这位病人应诊断为AIDS,的哪一类,哪一级经治疗后患者症状好转,淋巴细胞总数2.6×109/L,CD4+T淋巴细胞0.6×109/L,此时应诊断为AIDS的哪一类,哪一级
关于工作流程图的说法正确的是()。
()作为防止事故发生和减少事故损失的安全技术,是发现系统故障和异常的重要手段。
公开招标和邀请招标在招标程序上的差异为()。
MissHarperclosedhereyesand______(假装)tobeasleep.
关于唐代文学,下列表述错误的是:
Inhisnewbook,GoingSolo,NewYorkUniversitysociologistEricKlinenbergarguesthatwe’repoisedtobecomeanationdominat
Humansareuniqueamongprimatesforournear-totalbodilyhairlessness.Infact,onlyahandfulofthe5,000orsomammals—most
Mr.XucaughtSARSandsoonhisfamilymemberswere______.
最新回复
(
0
)