4、下面是冒泡法排序(升序),空白处应填入________。 Dim a(9) As Integer, i%, j%, t% For i = 0 To 9 a(i) = Int(Rnd() * 89 + 10) Next For i = 0 To 8 For j = 0 To ________ If a(j) > a(j + 1) Then t = a(j) a(j) = a(j + 1) a(j + 1) = t End If Next NextA.9B.iC.9 - iD.8 - i

4、下面是冒泡法排序(升序),空白处应填入________。 Dim a(9) As Integer, i%, j%, t% For i = 0 To 9 a(i) = Int(Rnd() * 89 + 10) Next For i = 0 To 8 For j = 0 To ________ If a(j) > a(j + 1) Then t = a(j) a(j) = a(j + 1) a(j + 1) = t End If Next Next

A.9

B.i

C.9 - i

D.8 - i


参考答案和解析
错误

相关考题:

下面是用冒泡法将5个整数按升序排列,请将程序补充完整。Sub GASR()Dim mm=Array(10, 1, 5, 6, 7)For i=0 To 3For j= 【13】If m(i) =m(j) Then【14】m(i) =m(j)m(j) =tEnd IfNext j【15】For i=0 To 4Print m(i)Next iEnd Sub

在窗体上画—今名称为Cmmand1的命令按钮,然后编写如下事件过程 Option Base 1 Private Sub Command1_Click() Dim a(5,5)As Integer For i=1 To 5 For j=1 To 5 a(i,j)=(i+j)*5\10 Next j Next i s=0 For i=1 To 5 s=s+a(i,i) Next i Print s End SubA.15B.13C.11D.9

以下程序的输出结果是 ______。 Dim n(2,2), i, j As Integer For i = 0 To 2 For j = 0 To 2 n(i,j) = i + j Next j Next i For i = 0 To 1 For j = 0 To 1 n(i+ 1 ,j + 1) = n(i + 1,j + 1) + n(i, j) Next j Next i Print n(i, j)A.14B.0C.6D.值不确定

阅读程序: 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 程序运行后,单击窗体,输入结果为______。A. 21B.13C.8D.25

下列程序段的执行结果为 ______。 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

有以下程序: 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 程序运行后,单击窗体,输出结果为______。A.813B.013C.712D.00

有如下语句,执行后该段语句的循环次数是()。 Dim s,I,j as integer For I =1 to 3 For j=3 To 1 Step-1 S=I*j Next j Next I A. 3B. 4C. 9D. 10

当Form1_Click事件发生时,窗体上显示的第三行是( )。 Option Base 1 Private Sub Form_Click() Dim i As Integer,j As Integer Dim k As Integer,a(5,5)As Integer For i=1 To 5 k=1 For j=1 To 5 If i<=j Then a(i,j)=k k=k+1 Else a(i,j)=1 End If Next j Next i For i=1 To 5 For j=1 To 5 Print a(i,j); Next j Print Next i End SubA.1 2 3 4 5B.1 1 2 3 4C.1 1 1 2 3D.1 1 1 1 2

以下程序的输出结果是 ( ) main( ) {int b[3][3]={0,1,2,0,1,2,0,1,2},i,i,t=1; for(i=0:i<3;i + +) for(j=j;j<=i;j + +)t=t+b[i][j] printf("%d\n",t); }A.3B.4C.1D.9

阅读程序: Option Base 1 Dim art()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 Next ReDim Preserve ale(3,4) For j=3 To 4 arr(3,j)=j+9 Next Print arr(3,2)+arr(3,4) End Sub 程序运行后,单击窗体,输出结果为A.21B.13C.8D.25

有下面的程序段,其功能是按图1所示的规律输出数据: Dim a(3,5)As Integer For i=1 To 3 For j=1 To 5 a(i,j)=i+j Print a(i,j); Next Print Next若要按图2所示的规律继续输出数据,则接在上述程序段后面的程序段应该是( )。A.For i=1 To 5 For j=1 To 3 Print a(j,i); Next Print NextB.For i=1 T0 3 For j=1 To 5 Print a(j,i); Next Print NextC.For j=l To 5 For i=1 To 3 Print a(j,i); Next Print NextD.For i=1 To 5 For=1 To 3 Print a(i,j): Next Print Next

以下程序的输出结果是 main() { int b[3][3]={0,1,2,0,1,2,0,1,2},i,j,t=1; for(i=0;i<3;i++) for(j=i;j<=i;j++)t=t+b[i][b[j][j]]; printf(“%d\n”,t); }A.3B.4C.1D.9

23 有如下程序段,该程序段循环的次数是______。 Dim i As Integer Dim j As Integer Dim k As Integer k=0 For i = 0 To 10 Step 3 For j = 1 To 5 If j > 3 Then k = k + 4: Exit For k=k+1 Print k Next j If i > 8 Then Exit For Next iA.9B.10C.11D.12

有如下事件过程,单击命令按钮扣,输出结果是 Private Sub Command1 Click( ) Dim b% (1 To4) ,j%, t# For j=1 To 4 b(j) =j Next j t=Tax(b( ) ) Print "t="; t, End Sub Function Tax (a( ) As Integer) Dim t#, i% t=1 For i=2 To UBound (A)t=t * a(i) Next i Tax=t End FunctionA.t=18B.t=24C.t=30D.t=32

阅读如下程序: Option Base 1 Private Sub Form Click() Dim Arr(4,4)As Integer For i=1 To 4 For j=1 To 4 Arr(i,j)=(i-1)*2+j Next j Next i For i=3 To 4 For j=3 To 4 Print Arr(j,i); Next j Print Next i End Sub 程序运行后,单击窗体,输出的结果为A.5 7 6 8B.6 8 7 9C.7 9 8 10D.8 10 8 11

下列程序段的招待结果是______ 。 s=0 t=0 u=0 For i = 1 To 3 For j = 1 To i For k = j To 3 s=s+ 1 Next k t=t+1 Next j u=u+ 1 Next i Print s; t; uA. 14 6 3B.6 14 3C.9 8 7D.8 9 10

在窗体上面1个名称为Command1的命令按钮,然后编写下列事件过程 Option Base 1 Private Sub,Command1 Click( ) Dim a(5,5)ks Integer For i=1 To j For j=1 To 5 a(i,j)=(i+j)*5\10 Next j Next i S=0 For i=1 To j s=s+a(i,i) Next i Print s End Sub 程序运行后,单击命令按钮,输出结果是( )。A.15B.13C.11D.9

当Form_Click;事件发生时,窗体上显示的第三行是 ______。 Private Sub Form_Click() Dim i As Integer, j As Integer, k As Integer Dim x(5, 5) As Integer For i = 1 To 5 k = 1 For j = 1 To 5 If i <= j Then x(i, j) = k + 1 k=k+2 Else x(i, j) = k + 1 End If Next j Next i For i = 1 To 5 For j = 1 To 5 Print x(i, j) Next j Print Next i End SubA.22135B.21357C.22213D.13579

请阅读程序. 0ption Base 1 Private Sub Fo,m Click( ) Dim Arr(4,4)As Integer For i=1 To 4 For j=1 To 4 Arr(i,j)=(i=1)*2+j Next j Next i For i=3 To 4 For j=3 To 4 Print Arr(j,i); Next j Print Next i End Sub 程序运行后,单。旨窗体,则输出结果是( )。A.5 7 6 8B.6 8 7 9C.7 9 8 10D.8 10 8 11

程序代码如下,当单击窗体上的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

在窗体中添加1个命令按钮(其Name属性为Command1)和1个标签(其Name属性为Lable1),然后编写如下代码: Private Sub Commandl_Cliek() Dim arrayl(10, 10)As Integer Dim i, j, Sum AsInteger Sum=0 For i=1 To 10 Forj=1 To 10 arrayl(i, j)=i+j Nextj Next i End Sub 此程序的功能是求数组arrayl主对角线元素的和,并把结果显示在标签中,为实现此功能,省略号处的程序段应该是 ( )A.For i=1 To 10 For j=1 To 10 If i=j Then Sum = Sum+ arrayl (i,j) End If Next j Next i Labelt. Caption=SumB.For i=l TO 10 Forj=1 To 10 If i= =j Then Sum=Sum+array1 (i,j) End If Next j Next i Labell. Caption=SumC.For i=1 To 10 For j=1 To l0 If i=j Then Sum=Sum+arrayl (i,j) End If Next i Next j Lahell. Caption=SumD.For i=1 To 10 For j=1 To l0 If i=j Then Sum=arrayl (i,j) End If Next j Next i Labell. Caption=Sum

以下程序的输出结果是 main() { int b[3][3]={0,1,2,O,l,2,0,1,2},i,j,t=1; for(i=0;i<3;i++) for(j=i;j<=i;j++) t=t+b[i][b[j][j]]; printf("%d\n",t); }A.3B.4C.1D.9

窗体上有一个名为Command1的命令按钮,并有下面的程序: Private Sub Command1 Click( ) Dim arr(5)As Integer . For k=1 To 5 art(k)=k Next k prog art( ) For k=1 T0 5 Print art(k); Next k End Sub Sub prog(a( )As Integer) n=UBound(a) For i=n To 2 step-1 if a(j)a(j十1)Then t=a(j):a(1)=a(j+1);a(j+1)=t End If Next j Next i End Sub 程序运行时,单击命令按钮后显示的是( )。A.12345B.54321C.01234D.43210

下面程序段的功能是()。……int a[]={4,0,2,3,1},i,j,t;for(i=0;=0 下面程序段的功能是( )。 …… int a[]={4,0,2,3,1},i,j,t; for(i=0;<5;i++) { t=a[i];j=i;j--; while(j>=0t>a[j]) {a[j+1]=a[j];j--;} a[j+1] =t; } ……A.对数组a进行插入排序(升序)B.对数组a进行插入排序(降序)C.对数组a进行选择排序(升序)D.对数组a进行选择排序(降序)

当Form1_Click事件发生时,窗体上显示的第三行是( )。 Dim i As Integer,j As Integer,a(5,5) As Integer For i=1 To 5 For j=1 To 5 If(i<=j)Then a(i,j)=1 Else a(i,j)=0 End If Next j Next i For i=1 To 5 For j=1 To 5 Print a(i,j), Next j Print Next i End SubA.0 0 0 1 1B.0 0 1 1 1C.0 1 1 1 1D.1 1 1 1 1

下列程序段的执行结果为______。 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

当发生Form_Click事件时,窗体上显示的第三行是( )。 Option Base 1 Private Sub Form_Click() Dim i As Integer,j As Integer,k As Integer Dim a(5,5)As Integer For i=1 To 5 k=1 For i=1 To 5 If(i<=j)Then a(i,j)=k k=k+2 Else a(i,j)=k+1 End If Next j Next i For i=1 To 5 For j=1 To 5 Print a(i,j); Next j Print Next i End SubA.1 3 5 7 9B.2 1 3 5 7C.2 2 2 1 3D.2 2 1 3 5

(8)以下程序的功能是:先将随机产生的10个不同的整数放入数组a中,再将这10个数按升序方式输出。请填空。Private Sub Form_Click()Dim a(10) As Integer, i As IntegerRandomizei=0Donum=Int(Rnd*90)+10For j=1To i ' 检查新产生的随机数是否与以前的相同,相同的无效If num=a(j)ThenExit ForEnd IfNext jIf j>i Theni=i+1a(i)=【10】End IfLoop While i<10For i=1 To 9For j=【11】To 10If a(1)>a(j)Then temp=a(i):a(i) = a(j):【12】Next jNext iFor i=1To10Print a(i)Next iEnd Sub