网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

下列程序的功能是求算式:1-1/2+1/3-1/4+....前30项之和。请在空白处填入适当的语句,使程序可以完成指定的功能。 Private Sub Command1_Click() Dim i as Integer, s As Single, f As Integer s = 0 : f = 1 For i = 1 To 30 s = s + f/i f =() Next i Debug.Print “1-1/2+1/3-1/4+…=”; s End Sub


参考答案和解析
根据题意, s=s+ 1 n n=n+2 ∴数列为 { 1 2n } 又∵K≤10 ∴计算的是求数列 { 1 2n } 的前10项和(n∈N * ) 故答案为:B
更多 “下列程序的功能是求算式:1-1/2+1/3-1/4+....前30项之和。请在空白处填入适当的语句,使程序可以完成指定的功能。 Private Sub Command1_Click() Dim i as Integer, s As Single, f As Integer s = 0 : f = 1 For i = 1 To 30 s = s + f/i f =() Next i Debug.Print “1-1/2+1/3-1/4+…=”; s End Sub” 相关考题
考题 在窗体中有一个命令按钮command1,编写事件代码如下: Private Sub Command1_Click() Dim s As Integer s=P(1)+P(2)+P(3)+P(4) Debug.Print s End Sub Public Function P(N As Integer) Dim Sum As Integer Sum=0 For i=1 To N Sum=Sum+1 Next i P=Sum End Function 打开窗体运行后,单击命令按钮,输出的结果是( )。A.15B.20C.25D.35

考题 设有如下程序:Private Sub Form_C1ick()Dim s As Long,f As LongDim n As Integer,i As Integerf=1n=4For i=1 To nf=f*is=s+fNext iPrint sEnd Sub程序运行后,单击窗体,输出结果是A.32B.33C.34 0)35

考题 在窗体上有一个命令按钮Commandl,通用过程fun和命令按钮的事件过程如下: Private Function fun(By m As Integer) If m Mod 2=0 Then fun=2 Else Fun=1 Else If End Funcion Private Sub Commandl_Click() Dim i Integer,s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,则窗体上输出A.6 B.7 C.8 D.9

考题 (8)下列这个Sub过程的功能是统计字符串中“a”的个数,请在空白处填上合适的代码,将程序补充完整。Private Sub numCount() Dim num As Integer s$="software And hardware" Num=Len(s$) For i=1 unm b$=。 If b$="a"Then x=x+1 Next i Print"x=";xEnd Sub

考题 (14)有下列程序,程序运行后单击命令按钮,则输出的结果是 Private Sub Command1_Click() Dim a%(1 To 4),b%(3 To 6),i%,s1#,s2# For i=1 To 4 a(i)=i Next i For i=3 To 6 b(i)=i Next i s1=Factorial(a) S2=Factorial(b) Print"s1=";s1;"s2";s2; End Sub Function Factorial(a()As Integer) Dim t#,i% t=1 For i=LBound(a) To UBound(a) t=t*a(i) Next i Factorial=t End Factorial A.s1=360 s2=24 B.s1=24 s2=360 C.s1=24 s2=24 D.s1=360 s2=360

考题 下列程序用来计算1+2+…n,当和大于100时停止计算,请填空。Private Sub Form_Click()Dim n as integer,s as integer,I as integer,k as integers=0k=0n=inputbox(″请输入n的值)For i=1 to 100k=k+1s=s+I【 】Next iPrint sEnd Sub

考题 下面运行程序后,单击命令按钮,输出的结果是 【 】 。Private Sub Command1_Click()Dim a%(1 To 5),i%, s#For i=1 To 5a(i)=iNexts=Fun(a)Print "s="; s;End SubFunction Fun(a() As Integer)Dim t#, i%t=1For i=LBound(a) To UBound(a)t=t  a(i)NextFun=tEnd Function

考题 下列程序的功能是求算式:1+1/2!+1/3!+1/4!+……前10项的和(其中n!的含义是n的阶乘)。请在空白处填入适当的语句,使程序完成指定的功能。Private Sub Commandl_Click ( )Dim i as integer,s as single,a as singlea=1:s=0For i=1 To 10a=_____s=s+aNext iDebug.Print“1+1/2!+1/3!+……=”;SEnd Sub

考题 设有如下程序: Private Sub Form. Click( ) Dim s As Long,f As Long Dim n As Integer,i As Integer f=1 n=4 For i=1 To n f=f*i s=s+f Next i Print s End Sub 程序运行后,单击窗体,输出结果是( )。A.32B.33C.34D.35

考题 阅读下列程序: Function func(n As Integer)As Integer Sum = 0 For i = 1 To n Sum = Sum + (i + 1)* i Next i func = Sum End Function.Private Sub Command1_Click () Dim a As Integer a= 5 s = func (A)Print s End Sub 程序运行后,单击命令按钮,输出的结果为A.80B.60C.70D.15

考题 现有如下程序: Private Sub Command1_Click() s=0 For i=1 To 5 s=s+f(5+i) Next Print s End Sub Public Function f(x As Integer) If x>=10 Then t=x+1 Else t=x+2 End If f=t End Function 运行程序,则窗体上显示的是( )。A.38B.49C.61D.70

考题 若有以下程序,当程序运行后,单击命令按钮,则输出的结果为( )。 Private Sub Command1_Click() Dim a%(1 To 4), b%(3 To 6), i%, s1#, s2# For i= 1 To 4 a(i) = i Next i For i=3 To 6 b(i) = i Next i s1 = Factorial (A) s2 = Factorial (B) Print "s1="; s1; "s2="; s2 End Sub Function Factorial(a() As Integer) Dim t#, i% t=1 For i = LBound(A)To UBound(A) t = t * a(i) Next i Factorial = t End FunctionA.s1=360 s2=24B.s1=24 s2=360C.s1=24 s2=24D.s1=360 s2=360

考题 在窗体上绘制一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程: Private Function fun(ByVal m As Integer) If m Mod 2=0 Then fun=2 Else fun=1 End If End Function Private Sub Command1_Click() Dim i As Integer,s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,在窗体上显示的是A.6B.7C.8D.9

考题 在窗体上画一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程; Private Function fun(ByVal m As Integer) If m Mod 2=0 Then fun=2 Else fun=1 End If End Function Private Sub Command1_C1ick() Dim i As Integer, s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,在窗体上显示的是______。A.6B.7C.8D.9

考题 下列程序的功能是求算式:1-1/24-1/3-1/4+…前80项之和。 PrivateSub Commandl Click( ) Dim i asinteger,S assingle.f as integer s=0:f=1 For i=1To 30 s=s+f/i f=__________ Next i Debug.Print”1-1/2+1/3—1/4+…=”:s End Sub 横线处应填写的内容是( )。A.1*fB.-l*fC.1*iD.-1*i

考题 下列程序运行后的输出结果是______。Private Sub f(k,s) s = 1 for j = 1 To k s=s*j Next jEnd SubPrivate Sub Command1_ Click () Sum = 0 for i = 1 To 3 Call f(i, s) Sum = Sum + s Next i Print Sum End SubA.0B.3C.6D.9

考题 下列程序的功能是求算式:1-1/24-1/3-1/4+…前80项之和。PrivateSub Commandl Click( )Dim i asinteger,S assingle.f as integers=0:f=1For i=1To 30s=s+f/if=__________Next iDebug.Print”1-1/2+1/3—1/4+…=”:sEnd Sub横线处应填写的内容是( )。A.1*fB.-l*fC.1*iD.-1*i

考题 程序代码如下,当单击窗体上的Command1控件时,在窗体上输出的结果是( )。 Private Sub Command1_Click() Dim aa(3,3)As Integer Dim i As Integer,j As Integer Dim s As Integer For i=0 To 3 For j=0 To 3 aa(i,j)=i*4+j+1 Next j Next i For i=0 To 3 s=s+aa(i,1) Next i Print s End SubA.32B.28C.30D.36

考题 编写如下事件过程: Option Base 1 Private Sub Form Click() Dim x1()As Integer Dim i As Integer Dim s As Integer ReDim x1(3) For i = 1 To UBound(x1) x1(i)=i + 1 Next i Call sub1(x1) For i = 1 To UBound(x1) s = s + x1(i) Next i Print s End Sub Private Sub sub1(n()As Integer) Dim i As Integer ReDim Preserve n(5) For i = 3 To 5 n(i)=n(i-1)*2 Next i End Sub 程序运行后,单击窗体,则窗体上显示的内容是A.6B.12C.24D.47

考题 下面程序运行后的结果是( )。 Private Sub Form_Click() Dim s As Integer,k As Integer,i As Integer,n As Integer s=1 fori=1 to 3 forj=i to 3 for k=j to istep-1 s=s*k nextk,J,i print s End SubA.6B.72C.144D.432

考题 在窗体上画一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程: Private Function f(m As Integer) If m Mod 2 = 0 Then f = m Else f = 1 End If End Function Private Sub Command1_Click() Dim i As Integer s = 0 For i = 1 To 5 s = s + f(i) Next Print s End Sub 程序运行后,单击命令按钮,在窗体上显示的是A. 11B.10C.9D.8

考题 单击窗体时,下列程序的执行结果是 Private Sub Invert(By Val xstr As String,ystr As String) Dim tempstr AS String Dim I AS Integer I=Len(xstr) Do While I>=1 tempstr=tempstr + Mid(xstr,I,1) I=I - 1 Loop ystr=tempStr End Sub Private Sub Form_Click( ) Dim s1 As String,s2 As String S1="abcdef" Invert S1,S2 Print S2 End SubA.abcdefB.afbecdC.fedcbaD.defabc

考题 在窗体上有一个命令按钮Command1,通用过程fun和命令按钮的事件过程如下: Private Function fun(ByVal m As Integer) If m Mod 2 = 0 Then fun=2 Else fun=1 End If End Function Private Sub Command1_Cliek() Dim i As Integer, s As Integer s=0 For i=1 To 5 s=s+fun(i) Next Print s End Sub 程序运行后,单击命令按钮,则窗体上输出( )。A.6B.7C.8D.9

考题 设有如下程序:Private Sub Form. Click( )Dim s As Long,f As LongDim n As Integer,i As Integerf=1n=4For i=1 To nf=f*is=s+fNext iPrint sEnd Sub程序运行后,单击窗体,输出结果是( )。A.32B.33C.34D.35

考题 阅读程序: Function F(a As Integer) b=0 Static c b=b+1 c=c+1 f=a+ b+ c End Function Private Sub Command1_Click() Dim S As Integer a=2 For i=1 To 3 Print P(A) Next i End Sub运行上面的程序,单击命令拄钮,输出结果为______ 。A.4 4 4B.4 5 6C.4 6 8D.4 7 9

考题 在窗体上画一个名称为Command1的命令按钮,然后编写如下通用过程和命令按钮的事件过程: Private Function fun(ByVal m As Integer) If m Mod 2=0 Then fun=2 Else fun=1 End If End Function Private Sub Command1_Click( ) Dim i As Integer,s As Integer S=0 For i=1 To 5 s=s+fun(i) Next Print 3 End Sub 程序运行后,单击命令按钮,在窗体上显示的是A.6B.7C.8D.9

考题 下列程序运行后的输出结果是______。Private Sub f(k,s)s=1For j=1 To ks=s*jNextEnd SubPrivate Sub Command1_Click()Sum=0For i=1 To 3Call f(i,s)Sum=Sum+sNextPrint SumEnd Sub

考题 试题11下列程序的功能是求算式:1-1/2+1/3-1/4+……前30项之和。请在空白处填入适当的语句,使程序可以完成指定的功能。Private Sub Command0_Click()Dim i As Single , s As Single,f As Singles=0 :f=1For i= 1 To 30s=s+f / if=___【11】__Next iDebug.Print “1-1/2+1/3-1/4+……=”;sEnd Sub