Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

PROBLEMA DE URNA DE BOLAS

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim p(5), l(5), f(5)
Dim r, k, i, j
f(0) = 0
For k = 1 To 5
l(k) = InputBox("ingrese l")
p(k) = InputBox("ingrese p")
f(k) = f(k - 1) + p(k)
Next
For i = 1 To 10
r = Rnd()
j=1
Do While r > f(j)
j=j+1
Loop
ListBox1.Items.Add(r)
ListBox2.Items.Add(l(j))
Next
End Sub
End Class
PROBLEMA DEL SEMAFORO
PROBLEMA DEL DEPOSITO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim w, i, l, q, t
w = 600
l = Int(3 + 10 * Rnd())
t=t+l
For i = 1 To 90
w = w - 10
If t = i Then
q = 30 + 13 * Rnd()
w=w+q
If w > 1000 Then
w = 1000
End If
l = Int(3 + 10 * Rnd())
t=t+l
End If
Next
TextBox1.Text = w
End Sub
End Class
PROBLEMA DE PLAYA DE ESTACIONAMIENTO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim k, j, h, s, t, a, l
Dim d(50)
l = -3 * Math.Log(1 - Rnd())
t=t+l

Do While t < 720


h=0
For k = 1 To 50
If t >= d(k) Then
s = 80 + 50 * Rnd()
d(k) = t + s
k = 50
h=1
End If
Next
If h = 0 Then
a=a+1
End If
l = -3 * Math.Log(1 - Rnd())
t=t+l
Loop
TextBox1.Text = a
End Sub
End Class
PROBLEMA DE PARADA DE AUTOBUSES

PROBLEMA DEL CAJERO


Public Class Form1
'Problema del cajero
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim t, d, s, c, te, toc, tp
'Se genera un valor de t antes de empezar el bucle
t = t - 3 * Math.Log(1 - Rnd()) 'El valor de l es exponencial, se genera de una
distribucion exponencial
Do While t <= 480
c=c+1
s = 8 + 5 * Rnd() 'el valor de s es uniforme, se genera de una distribucion lineal
If t >= d Then
toc = toc + t - d
d=t+s
Else
te = te + d - t
d=d+s
End If
'El valor de t se debe repetir antes del final del bucle
t = t - 3 * Math.Log(1 - Rnd())
Loop
tp = te / c
TextBox1.Text = tp
TextBox2.Text = toc
End Sub
End Class

You might also like