二维数组-----称为矩形数组

Module Module1

    Function AddElements()

        Dim a(,) As Integer = {{0, 0, 1}, {1, 2, 11}, {3, 6, 12}, {6, 9, 90}, {23, 1, 78}}
        Dim i, j As Integer
        For i = 0 To 4
            For j = 0 To 2
                Console.WriteLine(a(i, j))
            Next j
        Next i
    End Function


    Sub Main()

        Dim a As Integer = 100
        Dim b As Integer = 50
        AddElements()


        Console.ReadLine()

    End Sub

End Module
Module arrayApl
   Sub Main()
      'a jagged array of 5 array of integers
      Dim a As Integer()() = New Integer(4)() {}
      a(0) = New Integer() {0, 0}
      a(1) = New Integer() {1, 2}
      a(2) = New Integer() {2, 4}
      a(3) = New Integer() {3, 6}
      a(4) = New Integer() {4, 8}
      Dim i, j As Integer
      ' output each array element's value 
      For i = 0 To 4
          For j = 0 To 1
              Console.WriteLine("a[{0},{1}] = {2}", i, j, a(i)(j))
          Next j
      Next i
      Console.ReadKey()
   End Sub
End Module

猜你喜欢

转载自www.cnblogs.com/fpcbk/p/10750329.html