编写如下程序: Private Sub Command1_Click() Dim a(3, 3) As Integer Dim i As Integer, j As Integer For i = 1 To 3 For j =

admin2020-06-30  22

问题 编写如下程序:
Private Sub Command1_Click()
   Dim a(3, 3) As Integer
   Dim i As Integer, j As Integer
   For i = 1 To 3
      For j = 1 To 3
         If i > 1 And j > 1 Then
            a(i, j) = a(a(i - 1, j - 1), a(i, j - 1)) + 1
         Else
            a(i, j) = i * j
         End If
      Next j
   Next i
   For i = 1 To 3
      For j = 1 To 3
         Print a(i, j);
      Next j
      Print
   Next i
End Sub
程序运行后,单击命令按钮Command1,输出结果为

选项 A、1  2  3
2  3  1
3  2  3
B、1  2  3
2  1  1
3  1  1
C、1  2  3
2  0  0
3  0  0
D、1  2  3
2  2  2
3  3  3

答案A

解析 第一个For循环对数组a(3, 3)元素赋初值。根据循环体内的条件数组元素获得初值。第二个For循环进行数组元素的打印。选A)。
转载请注明原文地址:https://kaotiyun.com/show/MLHp777K
0

最新回复(0)