Option Base 1
Private a%(), b%(), c$()
Private Sub Command1_Click(Index As Integer)
Dim n%, i%, q$, w$, e$
If Index = 0 Then
n = Val(Text1(0))
ReDim a%(n), b%(n), c$(n)
Randomize
For i = 1 To n
a(i) = Int((Rnd * 99) + 1)
q = a(i) &IIf(a(i) <10, Space(3), Space(2)) &q
b(i) = Int((Rnd * 99) + 1)
w = b(i) &IIf(b(i) <10, Space(3), Space(2)) &w
e = a(i) + b(i) &IIf(a(i) + b(i) <100, Space(2), Space(1)) &e
Next
Text1(1) = q: Text1(2) = w
Else
For i = 1 To n - 1
e = a(i) + b(i) &IIf(a(i) + b(i) <100, Space(2), Space(1)) &e
Text1(3) = e
End If
End Sub
Private Sub Command1_Click()Dim a(1 To 5, 1 To 5) As Integer
Dim b(1 To 5, 1 To 5) As Integer
Randomize
Label1.Caption = ""
Label2.Caption = ""
For i = 1 To 5
For j = 1 To 5
a(i, j) = Int(Rnd * 90) + 10
Label1.Caption = Label1.Caption &a(i, j) &Space(2)
Next
Label1.Caption = Label1.Caption &vbCrLf
Next
For i = 1 To 5
For j = 1 To 5
b(i, j) = a(j, i)
Label2.Caption = Label2.Caption &b(i, j) &Space(2)
Next
Label2.Caption = Label2.Caption &vbCrLf
Next
End Sub
Private Sub Form_Load()
Label1.AutoSize = True
Label2.AutoSize = True
Label1.Caption = ""
Label2.Caption = ""
Command1.Caption = "生成方阵"
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)