下列程序段的执行结果为 ______。 Dim m(3,3)As Integer Dim i As Integer Dim j As Integer Dim K As Integer For i=1 To 3 m(i,i)=i Next For i=0 To 3 For j=0 To 3 x=x+m(i,j) Next Next Print xA.3B.4C.5D.6
下列程序段的执行结果为 ______。 Dim m(3,3)As Integer Dim i As Integer Dim j As Integer Dim K As Integer For i=1 To 3 m(i,i)=i Next For i=0 To 3 For j=0 To 3 x=x+m(i,j) Next Next Print x
A.3
B.4
C.5
D.6
相关考题:
下面的程序代码实现将一个一维数组中元素向右循环移动,移位次数由文本框Text输入。例如数组各元素的值依次为0,1,2,3,4,5,6,7,8,9,10;移动三次后,各元素的值依次为8,9,10,0,1,2,3,4,5,6,7。Private Sub Moveright(x()As Integer)Dim i As IntegerDim j As IntegerDim k As Integeri=UBound(x)j=x(i)For k=i To ______ Step-1_______Next kx(LBound(x))=jEnd SubPrivate Sub Command1_Click()Dim a(10)As IntegerDim i As IntegerDim j As IntegerDim k As IntegerFor i=0 To 10a(i)=iNext ij=Val(Text1.Text)k=0Dok=k+1Call MoveRight(a)Loop Until k=jFor i=0 To 10Print a(i);Next iEnd Sub
以下程序的功能是:将一维组 A 中的 100 个元素分别赋给二维数组 B 的每个元素并打印出来,要求把 A ( 1 )到 A ( 10 )依次赋给 B ( 1 , 1 )到 B ( 1 , 10 ),把 A ( 11 )到 A ( 20 )依次赋给 B ( 2 , 1 )到 B ( 2 , 10 ),……,把 A ( 91 )到 A ( 100 )依次赋给 B ( 10 , 1 )到 B ( 10 , 10 )。请填空。Option Base 1Private Sub Form_Click()Dim i As Integer,j As IntegerDim A(1 To 100) As IntegerDim B(1 To 10,1 To 10) As IntegerFor i=1 To 100A(i)=Int(Rnd * 100)Next iFor i=1 To ________For j=1 To ________B(i,j)= ________Print B(i,j);Next jPrintNext iEnd Sub
设有一个10个元素的数组,下列程序将该数组的第一个元素与第十个元素交换,第二个元素与第九个元素交换……,第五个元素与第六个元素交换,请补充完该程序。Private Sub Commnd1_Click()Dim a(1 To 10)As IntegerDim i As IntegerDim p As IntegerDim t As IntegerDim j As IntegerFor i=1 To 10a(i)=iNext iFor j=1 To 5【 】【 】【 】Next jFor i=1 To 10Print a(i)Next iEnd Sub
( 9 )以下程序的功能是:将一维数组 A 中的 100 个元素分别赋给二维数组 B 的每个元素并打印出来,要求把 A(1) 到 A(10) 依次赋给 B(1,1) 到 B(1,10) ,把 A(11) 到 A(20) 依次赋给 B(2,1) 到 B(2,10) , …… , 把A(91) 到 A(100) 依次赋给 B(10,1) 到 B(10,10) 。请填空。Option Base 1Private Sub Form_Click()Dim i As Integer, j As IntegerDim A(1 To 100) As IntegerDim B(1 To 10, 1 To 10) As IntegerFor i = 1 To 100A(i) = Int(Rnd * 100)Next iFor i = 1 To 【 9 】For j = 1 To 【 10 】B(i, j) = 【 11 】Print B(i, j);Next jPrintNext iEnd Sub
有如下程序:Private Sub Command1_Click()Dim k As Integer, m As IntegerDim p As Integerk=4: m=1p=PC(k, m) : Print p;p=PC(k, m) : Print pEnd SubPrivate Function PC(a As Integer, b As Integer)Static m As Integer, i As Integerm=0: i=2i=i + m + 1m=i + a + bPC=mEnd Function程序运行后,输出的结果为( )。A.4 6B.6 6C.8 8D.10 12
下列数组定义语句错误的是( )。A.k%=10Dim Arr(k)B.Const k%=10Dim Arr(k)C.Dim Arr1(10) As IntegerDim Arr2 (10)D.Dim Arr1(1 To 10)Dim Arr2(1 To 10, 2 To 11)
下列程序段的执行结果为 ______。 Dim m(3,3)As Integer Dim i As Integer Dim j As Integer Dim x As Integer For i=1 To 3 m(i,i)=i Next For i=0 To 3 For j=0 To 3 x=x+m(i,j) Next Next Print xA.3B.4C.5D.6
设有如下程序:Private Sub Form_Click()Dim ary(1 To 5)As IntegerDim i As IntegerDim sum As IntegerFor i=1 To 5ary(j)=i+1sum=sum+ary(i)Next 1Print sumEud Sub程序运行后,单击窗体,则在窗体上显示的是A.15B.16C.20D.25
阅读程序:Function fac(ByVal n As Integer)As IntegerDim temp As Integertemp=1For i%=1 To ntemp=temp*i%Next i%fac=tempEnd FunctionPrivate Sub Form_Click()Dim nsum As Integernsum=1For i%=2 To 4nsum=nsum+fac(i%)Next i%print nsumEnd Sub程序运行后,单击窗体,输出结果是A.35B.31C.33D.37
有如下的程序:Private Sub Command1_Click()Dim k As Integer,m AB IntegerDim P As Integerk=4:m=1P=Fun(k,m) =Print P;P=Fun(k,m) :Print PEnd SubPrivate Function Fun(a As Integer,b As Integer)Static m As Integer,i As Integerm=5:i=2i=i+m+1m=i+a+bFun=m\2End Function单击命令按钮后,输出结果为A. 2 2B.4 4C.5 5D.6 6
设有如下程序:Private Sub Form. Click( )Dim ary(1 To 5)As IntegerDim i As IntegerDim sum As IntegerFor i=1 To 5ary(i)=i+lsum=sum+ary(i)Next iPrint sumEnd Sub程序运行后,单击窗体,则在窗体上显示的是( )。A.15B.16C.20D.25
阅读以下说明及Visual Basic程序代码,将应填入(n)上处的字句写在对应栏内。[说明]字符组合:程序界面如图示,在文本框Text1中输入若干个任意字符,单击“颠倒”按钮,将这些字符按相反的顺序显示在标签Lable1 中,并在标签Labs1 2处显示字符的个数。例如:输入abcabc2,显示为 2cbabca,组成字符数为4。[Visual Basic 代码]Private Sub cmdshow_ Click (Dim n As IntegerDim I As IntegerDim str1 As StringN=Len ( Text1.Text )For I=n To Step- 1Str1=(1)Next ILabe11. Caption=Str1End SubPrivate Sub cmdcount_ Click ( )Dim n As IntegerDim in As IntegerDim i As IntegerDim j As IntegerDim flag As IntegerDim str1 As IntegerDim str2 As IntegerN=(2)Str1 =Mid$ ( Text1.Text, i. 1For I =2 To nStr2=mid$ ( Text1,Text,I,1M=Len (str1)(3)For j=1 To mIf (4) Then flag= 1; Exit ForNext jIf flag<>1 then str1=str1 str2Next ILable2.Caption=(5)End Sub
阅读以下说明及Visual Basic程序代码,将应填入(n)处的字句写在对应栏内。【说明】以下程序为求行列式X(5,5)的值S。【Visual Basic代码】Private Function col ( byval x ( 5,5 ) as integer ) as longdim fesult as longdim temp as longdim I as integerdim j as integerdim k as imegerresult = 0for I = to 5(1)for j = 1 to 5if I+j>6 thenk= ( 1+j ) mod 5elsek=1endiftemp=temp*x ( k,j )(2)result=(3)(4)(5)End function
有如下事件过程:Private Sub Form. Active ( )Dim Score (1 to 3) As IntegerDim i As IntegerDim t As VariantFori=3 To 1 step-1Score (i) = 2 * iNextFor Each t In ScorePrint tNextEnd Sub程序运行后窗体上显示的值为【 】。
以下程序用于求s=1+(1+2)+(1+2+3)+……(1+2+……100)的和,请补充完该程序。Dim n As IntegerDim i As IntegerDim j As LongDim s As Longn=100j=0s=0For i=1 To【 】J=【 】s=【 】Next iPrint s
在一个窗体上添加一命令按钮控件,名为Command1,事件过程如下,则执行结果是( )。Option Base 1Private Sub Command1_Click()Dim a(5) As IntegerDim k As IntegerDim total As Integera(1)=2a(2)=5a(3)=4a(4)=10a(5)=6For k=1 To 5total=total+a(k)Next kPrint totalEnd SubA.10B.15C.27D.35
以下程序的功能是:将一维数组A中的100个元素分别赋给二维数组B的每个元素并打印出来,要求把A(i)到A(10)依次赋给B(1,1)到B(1,10),把A(11)到A(20)依次赋给B(2,1)到B(2,10),……,把A(91)到A(100)依次赋给B(10,1)到B(10,10)。请填空。Option Base 1Private Sub Form_Click()Dim i As Integer,j As IntegerDim A(1 To 100)As IntegerDim B(1 To 10,1 To 10)As IntegerFor i=1 To 100A(i)=Int(Rnd*100)Next iFor i=1 To【 】For j=1 To【 】B(i,j)=【 】Print B(i,j);Next jPrintNext iEnd Sub
下列程序执行后,执行的结果是______ 。 Dim M(2) For i = 1 To 2 M(i) = 0 Next i k=2 For i = 1 To k For j = 1 To k M(j) = M(i) + 1 Print M(k): Next j Next IA.1234B.0123C.223D.2345
下列程序段执行后,执行的结果是______ 。 Dim M(10) Dim N(10) i=3 For j = 1 To 5 M(j) = j N(i) = 2 * i + j Next j Print N(i); M(i)A.12 4B.11 3C.3 11D.10 2
Private Sub Commandl Click()Dim i As Integer, j As IntegerDim a (10,10)As IntegerFor i=1 To 3For j= i To 3a(i,j)=(i-1)*3+jPrint a (i,j);Next jPrintNext iEnd Sub程序运行后,单击命令按钮,窗体上显示的是( )。
有如下的程序。Private Sub Command1_Click()Dim k As Integer, m As IntegerDim P As Integerk=4: m=1P=Fun(k, m) : Print P;P=Fun(k, m) : Print PEnd SubPrivate Function Fun(a As Integer, b As Integer)Static m As Integer, i As Integerm=5: i=2i=i + m + 1m=i + a + bFun=m \ 2End Function单击命令按钮后,输出结果为A.2 2B.4 4C.5 5D.6 6
以下程序段运行的结果是______。Dim a(-1 To 5) As BooleanDim flag As Booleanflag = FalseDim i As IntegerDim j As IntegerDo 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 NextLoopPrint jA.20B.7C.35D.8
设执行以下程序段时依次输入2,4,6,执行结果为Dim a(4)As IntegerDim b(4)AS IntegerFor k=0 To 2a(k+1)=Val(InputBox("Enter data:"))b(3 - k) =a(k + 1)Next kPrint b(k)A.2B.4C.6D.0
下列程序段的执行结果为______。 Dim m(3,3)As Integer Dim i As Integer Dim j As Integer Dim x As Integer For i=1 To 3 m(i,i)=i Next For i=0 T0 3 For j=0 To 3 x=x+m(i, j) Next Next Print xA.3B.4C.5D.6
阅读程序:Function fac(ByVal As Integer)As IntegerDim temp As Integertemp=1For i%=1 To ntemp=temp*i%Next i%fac=tempEnd FunctionPrivate Sub Form. Click( )Dim nsum As Integernsum=1For i%=2 T0 4nsum=nsum+fac(i%)Next i%Print nsumEnd Sub程序运行后,单击窗体,输出结果是( )。A.35B.31C.33D.37