Private Function power (a As Integer, n As Integer) As Long
D.im p As Long
p=a
F.or k=1 To n
p=p*a
Next k
power=p
E.nd Function
在调试时发现是错误的,例如 Print power(5,4)的输出应该是 625,但实际输出是 3125。程序需要修改。
下面的修改方案中有 3 个是正确的,错误的一个是( )。
A.)把 For k=1 To n 改为 For k=2 To n
B.)把 p=p*a 改为 p=p^n
C.)把 For k=1 To n 改为 For k=1 To n-1
D.)把 p=a 改为 p=1
[单选题]为计算a“的值,某人编写了函数power如下:Private Function power(a As Integer,n As Integer)As LongD.im P As LongP=aF.or k=l T0 nP=P * aNext kpoWer=PE.nd Function在调试时发现是错误的,例如Print power(5,4)的输出应该是625,但实际输出是3125。程序需要修改。下面的修改方案中有3个是正确的,错误的一个是A.把For k=1 To n改为For k=2 To n
[单选题]为计算a"的值,某人编写了函数power如下:在调试时发现是错误的,例如Print power(5,4)的输出应该是625,但实际输出是3125。程序
[单选题]为计算an的值,某人编写了函数power如下:在调试时发现是错误的,例如Print power(5,4)的输出应该是625,但实际输出的是3125。程
[单选题]某人为计算n!(0<n<=12)编写了下面的函数过程:Private Function fun(n As Integer)As LongD.im P As LongP=1F.or k=n-1 To 2 Step-1P=P*kNext kfun=PE.ndFunction在调试时发现该函数过程产生的结果是错误的,程序需要修改。下面的修改方案中有3种是正确的,错误的方案是A.把P=1改为P=nB.把For k=n-1 To 2 Step-1改为For k=1 To n-lC.把For k
[单选题]设a、b都是自然数,为求a除以b的余数,某人编写了以下函数:F.unction fun(a As Integer,b As Integer)While a>ba=a-bWendfun=aE.nd Function在调试时发现函数是错误的。为使函数能产生正确的返回值,应做的修改是A.把a=a-b改为a=b-aB.把a=a-b改为a=a\bC.把While a>b改为While a<bD.把While a>b改为While a>=b
[单选题]某人编写了下面的程序Private Sub Commandl_click()D.im a As Integer,b As Integera=InputBox(“请输入整数”)b=InputBox(“请输入整数”)pro apro bC.allpro(a+B)E.nd SubPrivate Sub pro(n As Integer)While(n>0)Print n Mod 10;n=n\10WendPrintE.nd Sub此程序功能是:输入2个正整数,反序输出这2个数的每一位数字,再反序
[单选题](35)某人编写了下面的程序Private Sub Command1_Click( )D.im a As Integer, b As Integera=InputBox("请输入整数")b=InputBox("请输入整数")pro apro bC.all pro(a+b)E.nd SubPrivate Sub pro(n As Integer)While (n>0)Print n Mod 10;n=n/10WendPrintE.nd Sub此程序功能是:输入 2 个正整数,反序输出
[单选题]某人编写了下列程序,用来求10个整数(整数从键盘输入)中的最大值: Private Sub Command1_Click() Dim a(10) As Integer, max As Integer For k=1 To 10 a(k)=InputBox("输入一个整数") Next k max=0 For k=1 To 10 If a(k)>max Then max=a(k) End If Next k Print max End Sub 运行程序时发现,当输入10个正数时,可以得到正确结
[单选题]编写了如下事件过程: Private Sub Form_MouseDown(KeyCode As Integer,Shift As Integer) If (Button And 3)=3 Then Print"AAAA" End If End Sub 程序运行后,为了在窗体上输出“AAAA”,应按下的鼠标键是A.左B.右C.同时按下左和右D.按什么键都不显示
[单选题]编写了如下事件过程: Private Sub Form_KeyDown(KeyCode As Integer,Shift As Integer) If(Button And 3)=3 Then Print "AAAA" End If End Sub 程序运行后,为了在窗体上输出"AAAA",应按下的鼠标键是A.左B.右C.同时按下左和右D.按鼠标键没有反应