Private Sub Form_Activate()
Dim n As Integer
n = 10 '用户在这里规定
Dim a(10) As String
For i = 1 To n
a(i) = ""
For j = 1 To n
If i = j Or i - j = 1 Or j - i = 1 Then
a(i) = a(i) & " " & 1
Else
a(i) = a(i) & " " & 0
End If
Next
Next
For i = 0 To n
Print a(i)
Next
End Sub
Option Explicit
Option Base 1
Dim a(), n%, i%, j%
Private Sub Command1_Click()
Cls
n = Text1.Text
ReDim a(n, n)
For i = 1 To n
For j = 1 To n
If i = j Or i + j = n + 1 Then
a(i, j) = 1
Else
a(i, j) = 0
End If
Next j
Next i
For i = 1 To n
For j = 1 To n
Print a(i, j);
Next j
Print
Next i
End Sub
Private Sub Form_Click()
Dim a(1 To 5, 1 To 5) As Integer
For i = 1 To 5
a(i, i) = 1
a(i, 6 - i) = 1
Next i
For j = 1 To 5
For k = 1 To 5
Print a(j, k);
Next k
Print
Next j
End Sub