早教吧作业答案频道 -->数学-->
TheEuclideanalgorithmisusedtofindthegreatestcommondivisor(gcd)oftwopositiveintegers(继续)aandb.input(a)input(b)whileb>0beginr:=amodba:=bb:=rendgcd:=aoutput(gcd)Whenthealgorithmisusedtofin
题目详情
The Euclidean algorithm is used to find the greatest common divisor (gcd) of two positive integers
(继续)a and b.
input (a)
input (b)
while b>0
begin
r:=a mod b
a:=b
b:=r
end
gcd:=a
output(gcd)
When the algorithm is used to find the greatest common divisor of a =273 and b=110, which of the following is the sequence of computed values for r?
(A)2,26,1,0
(B)2,53,1,0
(C)53,2,1,0
(D)53,4,1,0
(E) 53,5,1,0
选D,怎么做的?
程序里的":="是什么意思?
(继续)a and b.
input (a)
input (b)
while b>0
begin
r:=a mod b
a:=b
b:=r
end
gcd:=a
output(gcd)
When the algorithm is used to find the greatest common divisor of a =273 and b=110, which of the following is the sequence of computed values for r?
(A)2,26,1,0
(B)2,53,1,0
(C)53,2,1,0
(D)53,4,1,0
(E) 53,5,1,0
选D,怎么做的?
程序里的":="是什么意思?
▼优质解答
答案和解析
这是求最大公约数的算法,在这个程序中":="应该就是赋值号,就是把符号右边变量的值赋给左边变量,mod是取余的函数,循环语句中
第一次 a=273 ,b=110 ,a/b的余数r=53
第二次 a=110 ,b=53 ,r=4
第三次 a=53 ,b=4 ,r=1
第四次 a= 4 ,b=1 ,r=0
因而r 的取值为 D
第一次 a=273 ,b=110 ,a/b的余数r=53
第二次 a=110 ,b=53 ,r=4
第三次 a=53 ,b=4 ,r=1
第四次 a= 4 ,b=1 ,r=0
因而r 的取值为 D
看了TheEuclideanalg...的网友还看了以下:
3)“可是,我……我还没有向你请教呢……”这句话中的省略号的作用分别是()和()A、表示话没说完B 2020-05-15 …
果蝇的体色由常染色体上的一对等位基因控制果蝇的体色由常染色体上一对等位基因控制,基因型BB、Bb为 2020-05-17 …
果蝇的体色由常染色体上一对等位基因控制,基因型BB、Bb为灰身,bb为黑身.若人为地组成一个群体, 2020-05-21 …
果蝇的体色由常染色体上一对等位基因控制,基因型BB、Bb为灰身,bb为黑身.若人为地组成一个群体, 2020-05-23 …
这些代码什么意识?BEGIN:VCARDVERSION:2.1N;CHARSET=UTF-8;EN 2020-07-09 …
一般人对苯硫腺感觉味苦,由基因B控制,也有人对其无味觉,叫味盲,由基因b控制。若三对夫妇的子女味盲 2020-07-10 …
TheEuclideanalgorithmisusedtofindthegreatestcommon 2020-10-30 …
下列杂交组合产生的后代,哪一组会发生性状分离()A.BB×BbB.BB×BBC.Bb×BbD.bb× 2020-11-22 …
已知一批豌豆种子中胚的基因型为BB和Bb的种子数之比为2:1,将这批种子种下去,自然状态下(假设结实 2020-11-29 …
vfp中计算连续自然数之和,并且显示和刚大于1000的最后一个自然数.bb=bb+1,aa=aa+b 2021-01-31 …