Добавил:
ivanov666
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Объектно-ориентированное программирование на языке Visual Basic 2008 в среде разработки Microsoft Visual Studio 2008 и .NET Framework. Часть 2. Учебно
.pdf
2
.
,
, , .
, :
1. .
2. .
3. , .
4. .
5. .
6. UBound .
1. . 1.
2. .
3. .
4. .
5. .
6. .
7. .
8. .
9.
.
1
A(m, n) mn ( m n ). -
1
. .
2
(m, n) mn ( m n ). -
. .
3 A(m, k) B(k,n). C(m, n), -
.
4 (m, n) p<m q<m. p
q.
5 (m, n). ,
, .
6 (m, n).
.
7 X(m, n).
. , ,
.
8 X(m, n).
. , ,
.
31

9 X(m, n). ,
ܺ
, a<X(i, j)<b.
10 X(m, n),
.
11 X(n, n). ,
.
12 X(n, n).
.
13 X(n, n). -
, ,
.
14
mn X(i, j)=i·10+j.
.
15
mn X(i, j)=10*sin(i+j).
, .
16 (n, n). <n q<n
q, q p.
17 X(m, n). ,
( ) .
18 X(m, n). ,
( ) .
19 X(m, n). , -
i- .
20 X(m, n). , -
j- .
21 (m, n). , -
.
22 (m, n). ,
.
23 (m, n). , -
, . , .
24 X(n, n). p q
σȁ
d=
ܺሺǡ݅ሻȉ
ୀ
, .
ሺݍǡ݅ሻ
ȁ
25 (m, n) , ..
. i
j
M(i, k)·M(j, k) = M(i, 0)·M(j, 0) + M(i, 1)·M(j, 1) + …+ M(i, n)·M(j, n).
26 , -
.
27 , -
.
28 , .
29 .
30 .
31 (n, n). ,
(2·n – 1) , .
32 M(n, n) 0 1.
kk, .
32

1. .
2. .
3. .
4. .
5. , -
.
6.
7. .
.
ArrayTwoDimension
transpositionMatrix rotationMatrix.
mas clockwise
input1() display().
:
display(ByVal mas1(,) As Integer, ByVal Cont As TextBox, ByVal m As Integer, _
ByVal n As Integer)
(
),
, ( )
transpositionMatrix , rotationMatrix
- 90 .
. 90 , , , . , ,
- ..,
, – ..
, , -
mas() mn
clockwise() nm.
mas(2,4) 3 5 ,
5 3 .
33

0,0 0,1 0,2 0,3 0,4
1,0 1,1 1,2 1,3 1,4
2,0 2,1 2,2 2,3 2,4
mas(2,4) (4,2)
2,0 1,0 0,0
2,1 1,1 0,1
2,2 1,2 0,2
2,3 1,3 0,3
2,4 1,4 0,4
clockwise(4,2)
clockwise(j, i) =
mas(m - i, j)
clockwise(4,2)
0,0 0,1 0,2
1,0 1,1 1,2
2,0 2,1 2,2
3,0 3,1 3,2
4,0 4,1 4,2
1. .
2. ArrayTwoDimension .
3. transpositionMatrix rotationMatrix
ArrayTwoDimension
.
4. , Button -
TextBox1.
5. Button .
6. Visual Studio.
7.
.
,
34

Public Class ArrayTwoDimension
Friend mas(,) As Integer = {{}, {}}
Friend clockwise(,) As Integer = {{}, {}}
Friend m, n As Integer
Public Sub input1()
m = CInt(InputBox(" "))
n = CInt(InputBox(" "))
ReDim mas(m, n)
ReDim clockwise(n, m)
For i As Integer = 0 To m
For j As Integer = 0 To n
mas(i, j) = CInt(InputBox(" " & i & "- " & j & "- "))
Next
Next
End Sub
Public Sub display(ByVal mas1(,) As Integer, ByVal Cont As TextBox, ByVal m As Integer, _
ByVal n As Integer)
For i As Integer = 0 To m
For j As Integer = 0 To n
Cont.Text = Cont.Text & mas1(i, j) & " "
Next j
Cont.Text = Cont.Text & vbCrLf
Next i
End Sub
End Class
transpositionMatrix
Public Class transpositionMatrix
Inherits ArrayTwoDimension
Public Sub transposition()
Dim r As Integer
For i As Integer = 0 To n - 1
For j As Integer = i + 1 To n
r = mas(i, j) : mas(i, j) = mas(j, i) : mas(j, i) = r
Next j
Next i
End Sub
End Class
rotationMatrix
Public Class rotationMatrix
Inherits ArrayTwoDimension
Public Sub rotation()
For i As Integer = 0 To m
For j As Integer = 0 To n
clockwise(j, i) = mas(m - i, j)
Next: Next
End Sub
End Class
35

Form1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Dim k As Integer
Dim mm As New transpositionMatrix
mm.input1()
Dim m0 As Integer = UBound(mm.mas, 1)
Dim m1 As Integer = UBound(mm.mas, 2)
If m0 = m1 Then
TextBox1.Text = ""
TextBox1.Text = TextBox1.Text & " " & vbCrLf
mm.display(mm.mas, TextBox1, m0, m1)
mm.transposition()
TextBox1.Text = TextBox1.Text & " " & vbCrLf
mm.display(mm.mas, TextBox1, m0, m1)
Else
k = MsgBox(" ,
? ", MsgBoxStyle.YesNo)
If k = vbYes Then
End
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
Dim mt As New rotationMatrix
mt.input1()
Dim m0 As Integer = UBound(mt.mas, 1)
Dim m1 As Integer = UBound(mt.mas, 2)
TextBox1.Text = ""
TextBox1.Text = TextBox1.Text & " " & vbCrLf
mt.display(mt.mas, TextBox1, m0, m1)
mt.rotation()
TextBox1.Text = TextBox1.Text & " , 90 . "
& vbCrLf
mt.display(mt.clockwise, TextBox1, m1, m0)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
End
End Sub
End Class
.2.1
36

.2.1
37

3
.
:
x , .
x , .
x , .
x .
x .
x .
Visual Basic 2008 , , . -
New.
, .
.
.
.
Student, mName, mCourse
mBirthDate.
(.. ) .
,
, .
Public New
Public Class Student
Public mName As String
Public mCourse As Integer
Private mBirthDate As Date
Public Sub New() ‘
mName = “Smith”
mCourse = 4
End Sub
End Class
, mStudent mName
“Smith”, mCourse 4.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
End Sub
Dim mStudent As New Student
MsgBox(mStudent.mName & " " & mStudent.mCourse)
, .
, ,
38

New. ,
Public Class Student
Public mName As String
Public mCourse As Integer
Private mBirthDate As Date
Public Sub New(ByVal name As String, ByVal course As Integer)’
mName = name
mCourse = course
End Sub
End Class
tStudent,
New
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)_
Handles Button1.Click
Dim tStudent As New Student ("Smith ", 4)
End Sub
MsgBox(tStudent.mName & " " & tStudent.mCourse)
, ,
.
, -
(ptional) . -
:
Public Class Student
Public mName As String
Public mCourse As Integer
Private mBirthDate As Date
Public Sub New(Optional ByVal name As String = "Gardener", Optional ByVal course As _
Integer = 2)
mName = name
mCourse = course
End Sub
End Class
End Sub
End Class
( , ).
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
39

Dim pStudent As New Student("Smith ", 4)
Dim p1Student As New Student()
MsgBox(pStudent.mName & " " & pStudent.mCourse)
MsgBox(p1Student.mName & " " & p1Student.mCourse)
End Sub
, ,
( mName
"Smith ", mCourse 4. ,
mName "Gardener",
mCourse 2.
, Student
:
Public mName As String
Public mCourse As Integer
Public Specialty As String
Private BirthDate As Date
Public Sub New(ByVal name As String, ByVal course As Integer)
mName = name
mCourse = course
Specialty = "application programmer"
End Sub
End Class
Public Class Student
.
:
Public Class Student
Public mName As String
Public mCourse As Integer
Public Specialty As String
Private BirthDate As Date
Public Sub New(ByVal name As String, ByVal course As Integer)
mName = name
mCourse = course
Specialty = "application programmer"
End Sub
Public Sub New()
Specialty = "application programmer"
End Sub
End Class
, ,
Student
: ,
Name Course. :
40
Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]
