首页/ 题库 / [单选题]以下程序段运行的结果是 ______。 的答案

以下程序段运行的结果是 ______。 Dim a(-1 To 5)As Boolean Dim flag As Boolean flag=False Dim i As Integer Dim j As Integer Do Until flag=True For i=-1 To 5 j=j+1 If a(i)=False Then a(i)=True Exit For End If If i=5 Then flag=True End If Next Loop Print j

单选题
2022-01-06 02:44
A、20
B、7
C、35
D、8
查看答案

正确答案
C

试题解析
解析:该程序段的作用是给数组a的每个数组元素赋值True,具体实现的方式为: 每次从数组a的第一个元素开始判断,该元素是否为False,如果是,则令此元素为True,然后跳出循环,重新从数组a的第一个元素开始判断;如果当前元素不为False,则判断下一个元素。因此语句j=j+1将执行 1+2+3+4+5+6+7=28次,即j=28。然后再遍历一遍数组a的所有元素,最后结束程序段。所以j最终的值是: j=28+7=35。

标签:
感兴趣题目
下列程序段的执行结果为 ______。 Dim A(10),B(5) For i=1 To 10 A(i)=i Next i For i=1 To 5 B(j)=j*20 Next i A(5)=B(2) Print=A(5)= ";A(5)
下列程序段的执行结果为______。 Dim A(10),B(5) For i=1 To 10 A(i)=i Next i For j=1 To 5 B(j)=j*20 Next j A(5)=B(2) Print"A(5)="; A(5)
下列程序段的执行结果为 ______。 Dim A(10),B(5) For i=1 To 10 A(i)=i Next i For j=1 To 5 B(j)=j*20 Next j A(5)=B(2) Pring"A(5)=";A(5)
在窗体上画一个名称为Connand1的命令按钮,然后编写如下程序: Private Sub Command1_Click() Dim i As Integer, j As Integer Dim a(10, 10) As Integer For i = 1 To 3 For j = 1 To 3 a(i, j) = (i - 1) * 3 + j Print a(i, j); Next j Print Next i End Sub程序运行后,单击命令按钮,窗体上显示的是______。
已知有如下数组定义
Dim a(-3 To 6, 5, 3 To 10) As Integer
则执行语句Print LBound(a, 2); UBound(a, 2),输出的值为______。
下列程序段的执行结果为______。 Dim M(10), N(10) I=3 For T = 1 To 5 M(T) = T N(I) = 2 * I + T Next T Print N(I); M(I)
以下语句执行时,从键盘上输入Zhang,执行结果是______。 Dim a As String a=InputBox("Input","","Name") Print a
在窗体上画一个命令按钮,然后编写如下程序:Sub S1(ByVal x As Integer, By Val y As Integer) Dim t As Integer t=x x=y y=tEnd SubPrivate Sub Command1_ Click() Dim a As Integer, b As Integer a=10 b=30 S1 a,b Print "a=";a="b=";bEnd Sub 程序运行后,单击命令按钮,输出结果是______。
当Form_Click事件发生时,程序输出的结果是 ______。 Private Sub Form. Click() Dim a As Integer,b As Integer,c As Integer a=1: b=1 Print a; b Do c=a+b Print c a=b:b=c Loop Until c>=5 End Sub
阅读程序: Option Base 1 Dim arr()As Integer Private Sub Form_Click() Dim i As Integer,j As Integer ReDim arr(3,2) For i=1 To 3 For j=1 To 2 arr(i,j)=i*2+j Next j Next i ReDim Preserve arr(3,4) For j=3 To 4 arr(3,j)=j+9 Next j Print arr(3,2)+arr(3,4) End Sub 程序运行后,单击窗体,输入结果为______。
有以下程序: Option Base 1 Dim arr()As Integer Private Sub Form. Click() Dim i As Integer,j As Integer ReDim arr(3,2) For i=1 To 3 For j=1 To 2 arr(i,j)=i*2+j Next j Next i ReDim Preserve arr(3,4) For j=3 To 4 arr(3,j)=j+9 Next j Print arr(3,2);arr(3,4) End Sub 程序运行后,单击窗体,输出结果为______。
以下程序段的执行结果是 ______。 Dim a As Integer,b As Integer For a=4 To 1 Step-1 b=b+a Next a Print b, a
相关题目
下面程序运行后,第3次单击窗体后,窗体中输出的是______。Dim a As IntegerPrivate Sub Form_Click()Static c As IntegerClsa = a + 1b = b + 1End Sub
下面程序段执行后,输出的结果是______。Dim pi As Integerpi = 314159Print "pi"
已知有如下数组定义Dim a(-3 To 6, 5, 3 To 10) As Integer则执行语句Print LBound(a, 2); UBound(a, 2),输出的值为______。
有如下一个Sub过程: Sub mlt (ParamArray numbers()) n=1 For Each x In numbers n=n * x Next x Print n End Sub在一个事件过程中如下调用该Sub过程: Private Sub Coinmand1_Click() Dim a As Integer Dim b As Integer Dim c As Integer Dim d As Integer a=1 b=2 c=3 d=4 mlt a,b,c,d End Sub 则运行该程序,结果为______。
针对下面程序段,边界值问题可以定位在___(62)___。1:Rem Create a 10 element integer array2:Rem lnitialize each element to -13:Dim data(10) As Integer4:Dim i As Integer5:For i=1 TO 106:data(i)=-17:Next i8:End(62)
单击一次命令按钮之后,下更程序代码的执行结果为______ 。 Public Sub Proc(a() As Integer) Static i As Integer Do a(i) = a(i) + a(i + 1) i=i+1 Loop While i < 2 End Sub Private Sub Command1_Cliek() Dim m As Integer Dim i As Integer Dim x(10) As Integer For i = 0 To 4 x(i) = i + 1 Next i For i = 1 To 2 Call Proc (x) Next i For i = 0 To 4 Print x(i); Next i End Sub
在窗体上添加如下命令按纽,然后编写如下事件过程: Private Sub Command1_Click() Dim a(10)As Integer Dim p(3)As Integer k= 5 For i = 1 To 10 a(i) = i Next i For i = 1 To 3 p(i) = a(i * i) Next i For i = 1 To 3 k = k + p(i) * 2 Next i Print k End Sub该过程的运行结果为______。
下面程序:________Option Base 1Private Sub Command1_Click() Dim a(10),p(3)As Integer Dim i,k As Integer k=5 For i=1 To 10 a(i)=i Next For i=1 To 3 p(i)=a(i*i) Next For i=1 To 3 k=k+p(i)*2 Next Print kEnd Sub运行后的输出结果为________。
有如下程序,该程序的执行结果为______。 Dim k As Integer n=5 m=1 k=1 Do While k <= n m=m*2 k=k+1 Loop Print m
有如下程序,运行时输出的结果是 ______。 Option Base 1 Private Sub Command1_Click() Dim a(3,3) As Integer For m=1 To 3 For n=1 To 3 a(m-1,n-1)=m+n+1 Next n Next m For m=0 To 2 For n=0 To 2 Print a(n,m); Next n Print Next m End Sub
下列程序段的执行结果为______。Dim A(10),B(5) For i=1 To 10 A(i)=i Nex i For j=1 To 5 B(j)=j*20 Next j A(5)=B(2) Print "A(5)=";A(5)
以上程序段运行的结果是:______. Dim a(-1 To 5) As Boolean Dim flag As Boolean flag = False Dim i As Integer Dim j As Integer Do Until flag = True For i = -1 To 5 j=j+1 if a(i)= False Then a(i)= True Exit For End If If i = 5 Then flag = True End If Next Loop Print j
以下程序段运行的结果是______。 Dim a(-1 To 5)As Boolean Dim flag As Boolean flag=False Dim i As Integer Dim j As Integer Do Until flag=True For i=-1 To 5 j=j+l If a(i)=False Then a(i)=True Exit For End If If i=5 Then flag=True End If Next Loop Print j
以下程序段运行的结果是 ______。 Dim a(-1 To 5)As Boolean Dim flag As Boolean flag=False Dim i As Integer Dim j As Integer Do Until flag=True For i=-1 To 5 j=j+1 If a(i)=False Then a(i)=True Exit For End If If i=5 Then flag=True End If Next Loop Print j
有过程如下:Sub fact (m As Integer, total As Long) Dim i As Integer total = 1 for i = 1 To m total = total*i Next iEnd Sub调用它的事件过程如下:Private Sub Command1_ Click () Dim tot As Long Dim a As Integer a = Val InputBox (“请输入数据”)) Call fact (a, tot) Print totEnd Sub则输入数据5,运行结果为 ______。
用如下语句所定义的数组的元素个数是______个。 Dim b(-2 to 4)as string
用下面的语句定义的数组元素的个数是 ______。 Dim Arrl(-2 To 6)As Integer
语句Dim a(-3 To 4, 3 To 6)As Integer定义的数组的元素个数是______。
用下面语句定义的数组元素个数是______。 Dim Arr2(-2 To 6, i To 5) As Integer
用下面的语句定义数组元素的个数为 ______。 Option Base 1 Dim Arr6(-2 to 6, -1 to 5)As Integer
广告位招租WX:84302438

免费的网站请分享给朋友吧