Print a; b; i End Sub
(分数:4.00) 解析:8 13 22
32.执行下列程序,单击Command1按钮,在窗体上显示的变量a的值为 1,变量c的值为 2,窗体上的输出内容为 3。 Option Explicit
Private Sub Command1_Click()
Dim a As Integer, b As Integer, c As Integer a=1:b=2:c=3
Print fun(a, b, c)+fun(a, b, c) End Sub
Private Function fun(x As Integer, y As Integer, z As Integer)As Integer z=x x=x+y y=y+z z=x+y fun=x+y+z End Function
(分数:4.00) 解析:6 12 36
33.执行下列程序,单击命令按钮Command1后,数组元素A(2,3)的值是 1,A(3,3)的值是 2,A(4,3)的值是 3,文本框第一行的内容是 4。 Option Explicit Option Base 1
Private Sub Command1_Click()
Dim A(4, 4)As Integer, i As Integer, j As Integer, k As Integer For i=1 To 4 For i=1 To 4 k=k+1 A(i, j)=k Next j Next i
Call Transform(A) For i=1 To 4 For j=1 To 4
Text1=Text1&Space(1)&Format(A(i, j), \Next j
Text1=Text1&vbCrLf Next i End Sub
Private Sub Transform(A() As Integer)
Dim i As Integer, j As Integer, n As Integer, t As Integer, k As Integer n=UBound(A, 1) k=n+1
For i=1 To n/2 For j=1 To n
If i<>j And j<>k-i Then t=A(i, j)
A(i, j)=A(k-i, k-j) A(k-i, k-j)=t End If Next j Next i End Sub
(分数:6.00)
解析:7 11 2 01 15 14 04
34.执行程序,单击命令按钮Command1后,窗体上显示的第一行内容是 1,最后一行内容是 2。 Private Sub Command1_Click()
Dim A As Integer, B As Integer, K As Integer A=1:B=2
K=Fun((A), A)+Fun(A, B) Print K End Sub
Private Function Fun(N As Integer, M As Integer)As Integer Static K As Integer N=N+M K=K+N+M M=M+K+N Fun=N+M
Print Fun; M; N End Function
(分数:4.00) 解析:8 6 2 39
35.执行下列程序,单击按钮Command1后,数组元素A(1,1)的值是 1,A(3,3)的值是 2。 Option Base 1 Option Explicit
Private Sub Command1_Click()
Dim A(3, 3)As Integer, i As Integer, j As Integer, k As Integer k=10
For i=3 To 1 Step-1 For j=3 To i Step-1 k=k+1
A(j, i+3-j)=k Next Next
For i=2 To 1 Step-1 For j=1 To i k=k+1
A(i+1-j, j)=k Next Next For i=1 To 3 For j=1 To 3
Picture1.Print A(i, j); Next
Picture1.Print Next End Sub
(分数:4.00) 解析:19 11
36.执行下列程序,单击按钮Command1后,窗体上第一行内容是 1,第二行内容是 2,最后一行内容是 3。 Option Explicit
Private Sub Command1_Click()
Dim st As String, ch As String*1, t As Integer Dim i As Integer st=\For i=1 To Len(st) ch=Mid(st, i, 1)
If ch<>\<>\t=t*10+Val(ch) Else
If judge(t)Then Print t t=0 End If Next End Sub
Private Function judge(ByVal n As Integer) As Boolean Do While n<>1 If n Mod 2<>0 Then Exit Function End If n=n/2 Loop judge=True End Function
(分数:4.00) 解析:2 4 16
37.执行下列程序,单击按钮Command1,窗体第一行显示的结果是 1,UBound(A)的结果为 2,A(2)的值是 3。
Option Base 1 Option Explicit
Private Sub Command1_Click() Dim st As String, i As Integer
Dim A()As String, j As Integer, k As Integer st=\Process st Print st
For i=1 To Len(st) For j=i+1 To Len(st)
If Mid(st, i, 1)=Mid(st, j, 1)Then Exit For
Next
If i>Len(st)Then k=k+1
ReDim Preserve A(k) A(k)=Mid(st, i, 1) Print\End If Next End Sub
Private Sub Process(S As String) Dim i As Integer, t As String For i=1 To Len(S)/2 t=Mid(S, i, 1)
Mid(S, i, 1)=Mid(S, Len(S)-i+1, 1) Mid(S, Len(S)-i+1, 1)=t Next End Sub
(分数:4.00) 解析:csiab 5 i