dim a(10,10),b(100) as long
For i = 1 To 10
For j = 1 To 10
a(i, j) = "0"
Next j
Next i
For k = 1 To 20 '²¼À×
10: a1 = Int(Rnd * 10) + 1
b1 = Int(Rnd * 10) + 1
If a(a1, b1) = "0" Then
a(a1, b1) = "*"
n = n + 1
Else
GoTo 10
End If
Next k
'ÉèÖÃÀ×±ßÉϵÄÊý×Ö
For n = 2 To 9 'ÖмäÅжÏ
For t = 2 To 9
If a(n, t) = "*" Then
For n1 = n - 1 To n + 1
For t1 = t - 1 To t + 1
If a(n1, t1) <> "*" Then
a(n1, t1) = LTrim$(Str$(Val(a(n1, t1)) + 1))
End If
Next t1
Next n1
End If
Next t
Next n
For i = 2 To 9
If a(1, i) = "*" Then 'µÚÒ»ÐÐÅжÏ
For j = 1 To 2
For k = i - 1 To i + 1
If a(j, k) <> "*" Then
a(j, k) = LTrim$(Str$(Val(a(j, k)) + 1))
End If
Next k
Next j
End If
If a(10, i) = "*" Then 'µÚÊ®ÐÐÅжÏ
For j = 9 To 10
For k = i - 1 To i + 1
If a(j, k) <> "*" Then
a(j, k) = LTrim$(Str$(Val(a(j, k)) + 1))
End If
Next k
Next j
End If
Next i
For i = 2 To 9
If a(i, 1) = "*" Then 'µÚÒ»ÐУ¬µÚiÁÐÅжÏ
For j = i - 1 To i + 1
For k = 1 To 2
If a(j, k) <> "*" Then
a(j, k) = LTrim$(Str$(Val(a(j, k)) + 1))
End If
Next k
Next j
End If
If a(i, 10) = "*" Then 'µÚiÐУ¬µÚÊ®ÁÐÅжÏ
For j = i - 1 To i + 1
For k = 9 To 10
If a(j, k) <> "*" Then
a(j, k) = LTrim$(Str$(Val(a(j, k)) + 1))
End If
Next k
Next j
End If
Next i
'Ëĸö½ÇÅжÏ
If a(1, 1) = "*" Then 'µÚ1ÐУ¬µÚ1ÁÐÀ×ÅжÏ
For i = 1 To 2
For j = 1 To 2
If a(i, j) <> "*" Then
a(i, j) = LTrim$(Str$(Val(a(i, j)) + 1))
End If
Next j
Next i
End If
If a(1, 10) = "*" Then 'µÚ1ÐУ¬µÚ10ÁÐÀ×ÅжÏ
For i = 1 To 2
For j = 9 To 10
If a(i, j) <> "*" Then
a(i, j) = LTrim$(Str$(Val(a(i, j)) + 1))
End If
Next j
Next i
End If
If a(10, 1) = "*" Then 'µÚ10ÐУ¬µÚ1ÁÐÀ×ÅжÏ
For i = 9 To 10
For j = 1 To 2
If a(i, j) <> "*" Then
a(i, j) = LTrim$(Str$(Val(a(i, j)) + 1))
End If
Next j
Next i
End If
If a(10, 10) = "*" Then 'µÚ10ÐУ¬µÚ10ÁÐÀ×ÅжÏ
For i = 9 To 10
For j = 9 To 10
If a(i, j) <> "*" Then
a(i, j) = LTrim$(Str$(Val(a(i, j)) + 1))
End If
Next j
Next i
End If
For i = 1 To 100
b(i) = a((i - 1) \ 10 + 1, (i - 1) Mod 10 + 1)
Next i
布雷为:10*10型