Катя Дятчина
S:11:03:54 16.03
R:11:03:57 16.03
Module Module1
Public Structure Films
Public name As String, year, money As Integer
*Ввод структуры
Public Sub Vvod()
name = InputBox(*Название фильма*)
money = Val(InputBox(*Бюджет фильма*))
year = Val(InputBox(*Год выпуска*))
End Sub
*Формирование строки печати
Public Function Stroka() As String
Dim s As String
s = LSet((name), 20) + LSet((Str(money)), 10) + LSet((Str(year)), 10)
Stroka = s
End Function
End Structure
Public Sub VvodKv(ByRef n As Integer, ByRef St() As Films)
Dim i As Integer
n = Val(InputBox(*количество фильмов*))
ReDim St(n - 1)
For i = 0 To n - 1
St(i).Vvod()
Next
End Sub
*печать массива
Public Sub Pechat(ByVal n As Integer, ByVal St() As Films, ByRef lst As ListBox)
Dim i As Integer
lst.Items.Clear()
For i = 0 To n - 1
lst.Items.Add(St(i).Stroka)
Next
End Sub
Public Function Dorogo(ByVal n As Integer, ByVal st() As Films) As String
Dim i, maxvl As Integer
Dorogo = **
maxvl = Integer.MinValue
For i = 0 To n - 1
If st(i).money > maxvl Then
maxvl = st(i).money
Dorogo = st(i).name
End If
Next
End Function
Public Sub Sorti(ByVal n As Integer, ByRef St() As Films)
Dim i As Integer, sort As Boolean, buf As Films
Do
sort = True
For i = 0 To n - 2
If St(i).year > St(i + 1).year Then
sort = False
buf = St(i)
St(i) = St(i + 1)
St(i + 1) = buf
End If
Next
Loop Until sort = True
End Sub
Public Sub Formfilm(ByVal n As Integer, ByVal st() As Films, ByRef newst() As Films, ByVal yearf As Integer)
Dim i, k As Integer
k = -1
For i = 0 To n - 1
If st(i).year = yearf Then
k = k + 1
ReDim Preserve newst(k)
newst(k) = st(i)
End If
Next
End Sub
End Module