首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面的程序是找出两个正整数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
30
问题
下面的程序是找出两个正整数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/5Nmp777K
本试题收录于:
二级VB题库NCRE全国计算机二级分类
0
二级VB
NCRE全国计算机二级
相关试题推荐
一般来说,数据库的设计过程要经历3个大的阶段,即可行性分析与研究阶段、系统设计阶段、设计实施与系统运行阶段。概念设计、逻辑结构设计、物理结构设计属于数据库设计的______阶段。
下列Java布局管理器中,将容器按上北下南、左西右东,划分为东、南、西、北、中5部分的布局管理器是
执行下列程序之后,变量n的值为publicclassExam{publicstaticvoidmain(String[]args){inty=2;intz=3;intn=4
下列叙述中,错误的是()。
在数据管理技术发展的3个阶段中,数据共享最好的是()。
下列叙述中正确的是()。
在堆栈类SharedStack的定义中,为了保证堆栈在并发操作中数据的正确性,应在下划线处填入的修饰符是(两个下划线的填写内容相同)publicclassSharedStack(______intidx=0;______cha
某二叉树共有7个结点,其中叶子结点只有1个,则该二叉树的深度为______。(假设根结点在第1层)A)3B)4C)6D)7
请完善程序(程序文件名:Java_1.java)并进行调试。请在下画线处填入正确内容,然后删除下画线。请勿删除注释行和其他已有的语句内容。[题目要求]完善该程序并进行调试,使程序输出结果如下图所示。源程序://用2~20的偶数去
如果要在Applet中显示特定的文字、图形等信息,可以在用户定义的Applet类中重写的方法是
随机试题
男性,55岁,因高热一天来诊。查体:精神委靡,四肢末梢凉,T36.9℃,BP80/50mmHg,右肺下背部呼吸音弱,可闻及啰音,右上腹触痛(±)。
在PTH作用后几分钟内可导致血钙升高,其原因是
可体现补土生金法的方剂是
牙周病的影响因素不包括
A.四气B.五味C.升降浮沉D.归经E.毒性
孕妇的孕期保健措施中,不妥的是
资金流量表的编制分为两个部分进行,这两个部分分别为()。
借款需求是指公司为什么会出现资金短缺并需要借款。()
在讲授《木兰诗》时,教师引导学生对木兰诗进行内容分析,以下同学对诗歌《木兰诗》分析错误的一项是()。
求学者如果孜孜于衣食居住的安适,一定谈不上好学。同样,好学的目的也不是为________,心灵之养甚于居养之安。学习的目的是成为“有道”之人,名闻利养并非先务。这不是________物质,而是强调学习就是学习,不要附带上物质目的。依次填入画横线部分最恰当的
最新回复
(
0
)