Imports System
Public Class Program
Shared rows As Integer = 20
Shared columns As Integer = 20
Private Shared Sub PrintMatrix(ByVal matrix As Integer(,))
For i As Integer = 0 To matrix.GetLength(0) - 1
For j As Integer = 0 To matrix.GetLength(1) - 1
Console.Write(matrix(i, j).ToString().PadLeft(4) & " ")
Next
Console.WriteLine()
Next
End Sub
Private Shared Function generateRandomInteger(ByVal size As Integer) As Integer(,)
Dim random As Random = New Random()
Dim matrix As Integer(,) = New Integer(rows - 1, columns - 1) {}
For i As Integer = 0 To rows - 1
For j As Integer = 0 To columns - 1
matrix(i, j) = random.[Next](1, 101)
Next
Next
Return matrix
End Function
Public Shared Sub Main(ByVal args As String())
Dim matrix As Integer(,) = generateRandomInteger(20)
PrintMatrix(matrix)
End Sub
End Class
' run:
'
' 97 90 87 88 40 15 71 55 89 85 15 60 6 33 84 90 8 41 30 11
' 19 67 99 42 46 97 92 53 13 56 93 22 83 21 100 4 15 73 46 16
' 52 62 46 7 91 19 12 63 32 26 92 67 92 2 85 30 91 45 43 43
' 24 18 42 34 93 93 77 85 34 80 75 35 96 15 59 58 22 93 51 27
' 86 29 21 87 64 26 30 82 37 71 14 71 31 4 92 34 20 12 15 99
' 43 27 29 53 52 58 72 77 43 27 9 99 95 17 57 95 98 55 70 68
' 63 96 49 64 66 5 5 92 24 26 38 10 78 53 85 59 100 69 36 7
' 54 54 40 10 63 16 77 14 47 98 37 65 42 48 36 48 79 66 87 48
' 54 81 54 18 89 99 21 42 33 98 95 30 20 64 14 10 56 39 2 51
' 29 91 46 27 90 74 68 31 18 37 81 35 82 88 53 74 100 22 21 64
' 95 35 82 49 3 7 46 79 34 26 92 40 65 36 20 63 36 28 29 16
' 31 90 24 96 18 61 48 33 12 41 11 35 19 38 57 94 9 97 24 83
' 28 90 98 92 46 42 70 46 68 90 39 72 94 6 33 5 12 87 32 43
' 59 14 68 94 16 58 22 28 80 27 55 39 5 46 88 42 93 32 50 76
' 91 3 65 22 2 39 41 14 5 52 83 23 65 82 24 15 23 4 77 89
' 21 43 67 42 36 100 68 49 18 92 12 80 37 57 52 57 49 47 92 77
' 17 9 23 29 45 32 74 23 22 73 20 90 56 62 55 49 36 24 86 3
' 72 93 96 14 40 3 86 9 31 68 66 77 13 1 72 13 20 39 97 5
' 26 45 27 45 73 23 24 76 2 3 21 26 61 89 6 25 13 10 89 42
' 47 66 93 55 7 43 77 56 90 43 30 98 27 82 77 27 66 52 42 17
'