Vous êtes sur la page 1sur 5

tinka

Module Module1

Sub Main()
Console.Clear()
Dim n As Integer
ingresa(n)
Console.Clear()
Dim v(n), j(n, 6), jg(6), c(n), A(6) As Integer
generar(v, n)
jugada(j, n)
generar(jg, 6)
comparar(jg, j, n, c)
mostrarv(v, n, 2)
mostrarv(c, n, 70)
mostrar(jg, 6)
texto(n)
FRECUENCIA(c, A, n)
Console.ReadLine()
End Sub
Sub generar(ByVal V() As Integer, ByVal n As Integer)
Dim a, b, num As Integer
For a = 0 To n - 1
num = Rnd() * 41 + 1
If a > 0 Then
For b = 0 To n - 1
If num = V(b) Then
num = Rnd() * 41 + 1
b = -1
End If
Next
End If
V(a) = num
Next
End Sub
Sub jugada(ByVal j(,) As Integer, ByVal n As Integer)
Dim a, b, c, num As Integer
Console.ForegroundColor = ConsoleColor.Cyan
Console.WriteLine(" ")
Console.WriteLine(" ")
Console.WriteLine(" ")
For a = 0 To n - 1
Console.WriteLine(" ")
For b = 0 To 5
num = Rnd() * 41 + 1
If b > 0 Then
For c = 0 To 5
If num = j(a, c) Then
num = Rnd() * 41 + 1
c = -1
End If
Next
End If
j(a, b) = num
Console.Write("{0,10:F0}", j(a, b))
Next
Next
Console.WriteLine(" ")
End Sub
Sub comparar(ByVal jg() As Integer, ByVal j(,) As Integer, ByVal n As Integer,
ByVal c() As Integer)
Dim x, y, z As Integer
For x = 0 To n - 1
For y = 0 To 5
If jg(y) = j(x, y) Then
z = z + 1
End If
Next
c(x) = z
z = 0
Next
End Sub
Sub ingresa(ByRef n As Integer)
Console.Write("Ingrese el numero de jugadas: ")
n = Console.ReadLine
End Sub
Sub mostrarv(ByVal c() As Integer, ByVal n As Integer, ByVal a As Integer)
Dim x As Integer
Console.WriteLine(" ")
Console.ForegroundColor = ConsoleColor.DarkGreen
For x = 0 To n - 1
Console.SetCursorPosition(a, x + 4)
Console.WriteLine("{0}", c(x))

Next
End Sub
Sub mostrar(ByVal a() As Integer, ByVal n As Integer)
Dim i As Integer
Console.ForegroundColor = ConsoleColor.White
Console.BackgroundColor = ConsoleColor.Gray
Console.WriteLine()
Console.WriteLine(" JUGADA GANADORA
")
For i = 0 To n - 1
Console.BackgroundColor = ConsoleColor.Black
Console.Write("{0,10:D}", a(i))
Next
End Sub
Sub FRECUENCIA(ByVal C() As Integer, ByVal A() As Integer, ByVal N As Integer)
Dim X, Z, CO As Integer
For Z = 1 To 6
For X = 0 To N - 1
If C(X) = Z Then
CO = CO + 1
End If
A(Z) = CO
Next
CO = 0
Console.SetCursorPosition(30, Z + 20)
Console.WriteLine("{0}", A(Z))
Next
End Sub
Sub texto(ByRef n As Integer)
Dim x As Integer
Console.ForegroundColor = ConsoleColor.White
Console.SetCursorPosition(30, 0)
Console.WriteLine(" TINKA")
Console.SetCursorPosition(30, 1)
Console.WriteLine(" =====")
Console.SetCursorPosition(0, 2)
Console.WriteLine("CODIGO")
Console.SetCursorPosition(30, 2)
Console.WriteLine(" JUGADAS")
Console.SetCursorPosition(67, 2)
Console.WriteLine("ACIERTOS")
Console.SetCursorPosition(3, 21)
Console.WriteLine("GANADORES CON 1 ACIERTO: ")
Console.SetCursorPosition(3, 22)
Console.WriteLine("GANADORES CON 2 ACIERTOS: ")
Console.SetCursorPosition(3, 23)
Console.WriteLine("GANADORES CON 3 ACIERTOS: ")
Console.SetCursorPosition(3, 24)
Console.WriteLine("GANADORES CON 4 ACIERTOS: ")
Console.SetCursorPosition(3, 25)
Console.WriteLine("GANADORES CON 5 ACIERTOS: ")
Console.SetCursorPosition(3, 26)
Console.WriteLine("GANADORES CON 6 ACIERTOS: ")
For y As Integer = 2 To (n + 6)
Console.SetCursorPosition(6, y)
Console.WriteLine("|")
Console.SetCursorPosition(65, y)
Console.WriteLine("|")
Next
For x = 0 To 77
Console.SetCursorPosition(x, 3)
Console.WriteLine("-")
Next
End Sub

End Module
Module Module1

Sub Main()
Dim n, opc As Integer
ingresar(n)
Dim m(n, n) As Integer
crear(n, m)
mostrar(m, n)

suma_fila(m, n)

menu(opc)
Select Case (opc)

Case 1
Console.Write("la suma de filas es {0}", suma_fila(n, m))
Console.ReadLine()
Case 2
Console.Write("fin")
Console.ReadLine()
End Select
End Sub
Sub menu(ByRef opc As Integer)
Console.SetCursorPosition(15, 2)
Console.Write("matrices")
Console.SetCursorPosition(3, 4)
Console.Write("2. suma de filas")
Console.SetCursorPosition(4, 4)
opc = Console.ReadLine

End Sub
Sub ingresar(ByRef n As Integer)
Console.Write("ingrese el tamao de la matriz cuadrada")
n = Console.ReadLine
End Sub
Sub crear(ByVal n As Integer, ByRef m(,) As Integer)
Dim f, c As Integer
For f = 0 To n - 1
For c = 0 To n - 1
Console.WriteLine("ingrese los elementos {0},{1}", f, c)
m(f, c) = Console.ReadLine
Next c
Next f
End Sub
Sub mostrar(ByRef m(,) As Integer, ByRef f As Integer)
Dim c As Integer
For f = 0 To f - 1
For c = 0 To f - 1
Console.Write("{0}", m(f, c))
Next c
Next f

End Sub

Sub suma_fila(ByVal m(,) As Integer, ByRef n As Integer)


Dim f, c, suma As Integer
Console.Write("ingrese la fila a sumar")
f = Console.ReadLine
suma = 0
For c = 0 To n - 1
suma = suma + m(f, c)
Next c
Console.Write("la suma de la fila es {0}", suma)
Console.ReadLine()

End Sub

End Module

Vous aimerez peut-être aussi