设a、b都是自然数,为求a除以b的余数,某人编写了以下函数:Function fun(a As Integer,b As Integer)While aba=a-bWendfun=aEnd Function在调试时发现函数是错误的。为使函数能产生正确的返回值,应做的修改是A.把a=a-b改为a=b-aB.把a=a-b改为a=a\bC.把While ab改为While abD.把While ab改为While a=b
设a、b都是自然数,为求a除以b的余数,某人编写了以下函数:
Function fun(a As Integer,b As Integer)
While a>b
a=a-b
Wend
fun=a
End Function
在调试时发现函数是错误的。为使函数能产生正确的返回值,应做的修改是
A.把a=a-b改为a=b-a
B.把a=a-b改为a=a\b
C.把While a>b改为While a<b
D.把While a>b改为While a>=b
相关考题:
( 25 )设有以下函数过程Function fun(a As Integer,b As Integer)Dim c As IntegerIf ab Thenc=a:a=b:b=cEnd Ifc=0Doc=c+aLoop Until c Mod b=0fun=cEnd function若调用函数 fun 时的实际参数都是自然数,则函数返回的是A ) a 、 b 的最大公约数B ) a 、 b 的最小公倍数C ) a 除以 b 的余数D ) a 除以 b 的商的整数部分
( 29 )设 a 、 b 都是自然数,为求 a 除以 b 的余数,某人编写了以下函数:Function fun(a As Integer,b As Integer)While aba=a-bWendfun=aEnd Function在调试时发现函数是错误的。为使函数能产生正确的返回值,应做的修改是A )把 a=a-b 改为 a=b-aB )把 a=a-b 改为 a=a\bC )把 While ab 改为 While abD )把 While ab 改为 While a=b
设有以下函数过程:Function fun(a As Integer,b As Integer)Dim c As IntegerIf ab Thene=a:a=b:b=cEnd Ifc=0Doc=C+aroop Until c Mod b=0fun=cEnd Function若调用函数fun时的实际参数都是自然数,则函数返回的是A.a、b的最大公约数B.a、b的最小公倍数C.a除以b的余数D.a除以b的商的整数部分
如果Add函数的调用代码为:func main() {var a Integer = 1var b Integer = 2var i interface{} = asum := i.(Integer).Add(b)fmt.Println(sum)}则Add函数定义正确的是() A.type Integer intfunc (a Integer) Add(b Integer) Integer { return a + b}B.type Integer intfunc (a Integer) Add(b *Integer) Integer { return a + *b}C.type Integer intfunc (a *Integer) Add(b Integer) Integer { return *a + b}D.type Integer intfunc (a *Integer) Add(b *Integer) Integer { return *a + *b}
设a、b都是自然数,为求a除以b的余数,某人编写了以下函数: Eunction fun(a As Integer,b As Integer) While ab a=a—b Wend fun=a End Function 在调试时发现函数是错误的。为使函数能产生正确的返回值,应做的修改是( )。A.把a=a-b改为a=b-aB.把a=a-b改为a=a\bC.把While ab改为While a%bD.把While ab改为While a=b
设有以下函数过程: Function fun(a As Integer,b As Integer) Dim c As Integer If ab Then c=a:a=b:b=C End IF c=0 Do c=c+a Loop Until c Mod b=0 fun=c End Function 若调用函数fun时的实际参数都是自然数,则函数返回的是( )。A.a、b的最大公约数B.a、b的最小公倍数C.a除以b的余数D.a除以b的商的整数部分
设有以下函数过程:Function fun(a As Integer,b As Integer)Dim c As IntegerIf a<b Thenc=a:a=b:b=CEnd IFc=0Doc=c+aLoop Until c Mod b=0fun=cEnd Function若调用函数fun时的实际参数都是自然数,则函数返回的是( )。A.a、b的最大公约数B.a、b的最小公倍数C.a除以b的余数D.a除以b的商的整数部分