Листинг программы
Private Sub Command1_Click()
Dim l As Integer, m As Integer, tzad As Integer, Kmax As Integer
Dim Tobs As Variant
Dim Tosv() As Double
Dim Toch() As Double
Dim Potk As Double
Dim q As Double
SumL = 0
n = 1
5: SumP = SumP + Pmin
n = n + 1
x = 0.5
k = 0
Kotk = 0
Noch = 0
Toj = 0
Tsis = 0
Kobs = 0
Tnezan = 0
Tpost = 0
l = Val(Text1.Text)
Tobss = Val(Text2.Text)
m = Val(Text3.Text)
tzad = Val(Text4.Text)
Kmax = Val(Text5.Text)
ReDim Toch(m) As Double
ReDim Tosv(n) As Double
For i = 1 To n
Tosv(i) = 0
Next i
10: x = Rnd(x)
T = -1 / l * Log(x)
Tpost = Tpost + T
k = k + 1
If k > Kmax Then
GoTo 100
End If
30: Pmin = 1
Tmin = Tosv(1)
For i = 1 To n
If Tosv(i) < Tmin Then
Pmin = i
Tmin = Tosv(i)
End If
Next i
If Tpost < Tosv(Pmin) Then
GoTo 20
Else
GoTo 40
End If
20: If Noch = m Then
Kotk = Kotk + 1
GoTo 10
Else
Noch = Noch + 1
SumL = SumL + Noch
Toch(Noch) = Tpost
GoTo 10
End If
40: If Noch = 0 Then
Kobs = Kobs + 1
Tnezan = Tpost - Tosv(Pmin)
x = Rnd(x)
Tobs = -1 / (1 / Tobss) * Log(x)
Tosv(Pmin) = Tpost + Tobs
Tsis = Tsis + Tobs
GoTo 10
Else
Voj = Tosv(Pmin) - Toch(1)
For i = 1 To Noch - 1
Toch(i) = Toch(i + 1)
Next i
Noch = Noch - 1
Toj = Toj + Voj
x = Rnd(x)
Tobs = -1 / (1 / Tobss) * Log(x)
Tsis = Tsis + Tobs + Voj
If Tsis > tzad Then GoTo 5
Tosv(Pmin) = Tosv(Pmin) + Tobs
Kobs = Kobs + 1
oTo 30
End If
100: Potk = Kotk / Kmax
q = 1 - Potk
A = q * l
Ls = SumL / Kmax
Ps = SumP / n
Kpr = Tnezan / Tsis
Text6.Text = Str(Potk)
Text7.Text = Str(q)
Text8.Text = Str(A)
Text9.Text = Str(Ls)
Text10.Text = Str(Ps)
Text11.Text = Str(Kpr)
Text12.Text = Str(Tsis)
Text13.Text = Str(n)
End Sub