.


:




:

































 

 

 

 





4.8

 

 

 

 

4.8.4.

 

 

,

 

 

4.8.4.4.

 

 

 

 

 

, , , . , .

, , .

() () . , b(3,2):

 

b(0,0) b(0,1) b(0,2)
b(1,0) b(1,1) b(1,2)
b(2,0) b(2,1) b(2,2)
b(3,0) b(3,1) b(3,2)

 

, b(3,2) 2, .. ( ). b(3,2) 12 (4 3 ).

, Dim, . :

 

Dim b(3,2) As Single

 

, , A(m,n), A(i,j) , , ( . 4.8.1-1).

Array Rank Array GetLength(). Rank () ( 2). . GetLength() ( 0, 1 ..). , GetLength() , , Dim, VB , GetLength() , .

 

A(n,m) - n¹m A(n,m) - n=m

 

    j m
       
       
i   A(i,j)  
       
n      

 

      j   m
           
           
i          
           
n          

 

 

i=n-j i= j

 

. 4.8.1-1.

, Mac1(,),

 

Dim Mac1(4,7) As Integer

 

:

 

ArrayRank = Mac1.Rank RawCount = Mac1.GetLength(ArrayRank-2) ColumnCount= Mac1.GetLength(ArrayRank-1)

 

ArrayRank ( 2);

RawCount ( 5);

ColumnCount ( 8).

 

, ArrayRank, RawCount, ColumnCount , 2, 5 4.8.

, GetUpperBound(), ( ) . GetLength(), .. () 0, () 1.

, Mac2(4,7):

Dim Mac2(4,7) As Double Dim C1, 2 As Integer 1 = Mac2.GetUpperBound(0) ' 1 ' 4 2 = Mac2.GetUpperBound(1) ' 2 ' 7

 

, , , , . : . ( ), ( ), . , , .

 

4.8.1-1. /, .

4.3, 4.4, 4.5, 4.6 4.7. , , . 4.8.1-2, 4.8.1-3, 4.8.1-4 4.8.1-5.

 

' Single Sub vvodSngMac18(ByRef a(,) As Single) Dim i, j, m, n As Integer, y As Single m = a.GetLength(0) 1: n = a.GetLength(1) - 1 Dim r1, r2 As String For i = 0 To m For j = 0 To n r1 = Str(i): r2 = Str(j) y = InputBox("- a(" + r1 + "," + r2 + ") = ", _ " - a()") a(i,j) = CSng(Val(y)) Next j Next i End Sub

. 4.8.1-2.
vvodSngMac18() 4.8.1-1

 

' Sub vvod2(ByRef a(,) As Double, ByVal m As Integer, _ ByVal n As Integer) Dim i, j As Integer Randomize() For i = 0 To m For j = 0 To n a(i, j) = 10 * Rnd() - 5 Next i Next j End Sub

. 4.8.1-3. vvod2()

4.8.1-1

' - ListBox Sub vivodSngMac19(ByRef x(,) As Single, ByRef LB As ListBox) Dim i, j, m, n As Integer Dim z, z1 As String m = x.GetLength(0) 1: n = x.GetLength(1) - 1 LB.Items.Clear() For i = 0 To m z= "" For j = 0 To n z1 = Format(x(i,j), "0.000") If x(i,j) < 0 Then z1 = Space(2) + z1 Else z1 = Space(3) + z1 End If z = z + z1 Next j LB.Items.Add(z) Next i End Sub

. 4.8.1-4. vivodSngMac19()

4.8.1-1

. 4.8.1-4 TextBox. , , TextBox , MultiLine True.

 

' - Integer TextBox Sub vivodIntMac20(ByRef x(,) As Integer, ByRef TB As TextBox) Dim i, j, m, n As Integer Dim z As String m = x.GetLength(0) 1: n = x.GetLength(1) - 1 TB.Text = "" For i = 0 To m For j = 0 To n If Abs(x(i,j)) >= 100 Then z = CStr (x(i,j)) & Space(2) ElseIf Abs(x(i,j)) >= 10 Then z = CStr (x(i,j)) & Space(4) Else z = CStr (x(i,j)) & Space(6) End If If x(I,j) >= 0 Then z = Space(1) + z TB.Text = TB.Text & z Next j TB.Text = TB.Text & vbCrLf Next i End Sub

. 4.8.1-5.
vivodIntMac20 TextBox 4.8.1-1






:


: 2016-11-24; !; : 425 |


:

:

, - , ; , - .
==> ...

1416 - | 1439 -


© 2015-2024 lektsii.org - -

: 0.012 .