Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/02/2007, 12:49
manchester38
 
Fecha de Ingreso: febrero-2007
Mensajes: 2
Antigüedad: 18 años
Puntos: 0
prac 1

Imports system.IO
Imports System


Public Class Adivina
Shared Sub main()

Try

Dim ObjArchivo As TextWriter ' = Console.Out
ObjArchivo = File.CreateText(My.Application.Info.DirectoryPath & "\Jugadores.txt")
Inicio:
Console.WriteLine("PROPORCIONE EL NOMBRE")
nombre = Console.ReadLine
Console.WriteLine("TECLEE EL NUMERO INFERIOR")
strentrada = Console.ReadLine
intliminf = CInt(strentrada)
Console.WriteLine("TECLEE NUMERO SUPERIOR")
strentrada = Console.ReadLine
inc = TimeOfDay
intlimsup = CInt(strentrada)
intobj = objAleatorio.Next(intliminf, intlimsup + 1)
intpreg = 0 : intoport = 0
Do While intpreg <> intobj
Try
Console.WriteLine("ADIVINE EL NUMERO ALEATORIO")
strentrada = Console.ReadLine
intoport += 1
intpreg = strentrada
If intpreg < intobj Then Console.WriteLine("EL NUMERO ES MAYOR QUE: {0}", intpreg)
If intpreg > intobj Then Console.WriteLine("EL NUMERO ES MENOR QUE: {0}", intpreg)
Catch EXCEPTION2 As Exception
Console.WriteLine(EXCEPTION2.Message)
End Try
Loop
fin = TimeOfDay
Console.WriteLine("******************************* ******************************************")
Console.WriteLine("EL PARTICIPANTE ES: {0}", nombre)
Console.WriteLine("COMENZO A LAS: {0}", inc)
Console.WriteLine("CONCLUYO A LAS: {0}", fin)
Console.WriteLine("EL NUMERO GENERADO FUE: {0} ENTRE {1} AL {2}", intobj, intliminf, intlimsup)
Console.WriteLine("LOGRO ADIVINAR EN: {0} OPORTUNIDADES", intoport)
ObjArchivo.WriteLine("**************************** *********************************************")
ObjArchivo.WriteLine("EL PARTICIPANTE ES: {0}", nombre)
ObjArchivo.WriteLine("COMENZO A LAS: {0}", inc)
ObjArchivo.WriteLine("CONCLUYO A LAS: {0}", fin)
ObjArchivo.WriteLine("EL NUMERO GENERADO FUE: {0} ENTRE {1} AL {2}", intobj, intliminf, intlimsup)
ObjArchivo.WriteLine("LOGRO ADIVINAR EN: {0} OPORTUNIDADES", intoport)
Nom(Contador) = nombre
Inten(Contador) = intoport
Contador += 1
Console.ReadLine()
Console.WriteLine()
Console.WriteLine("Deseas jugar de nuevo? Si=1 No=2 ")
Dec = Console.ReadLine()
If Dec = 1 Then
GoTo Inicio
End If
For I = 0 To Contador - 1
For J = 0 To Contador - 1
If Inten(I) < Inten(J) Then
Aux = Inten(J)
Inten(J) = Inten(I)
Inten(I) = Aux
aux2 = Nom(J)
Nom(J) = Nom(I)
Nom(I) = aux2
End If
Next
Next
Console.WriteLine()
Console.WriteLine("Los Mejores jugadores")
For I = 0 To 2
Console.WriteLine("{0} {1} OPORTUNIDADES", Nom(I), Inten(I))
Next
'Console.SetOut(Auxi)
ObjArchivo.Close()
Console.ReadLine()
Catch EXCEPTION As Exception
Console.WriteLine(EXCEPTION.Message)
Console.ReadLine()
End Try
End Sub
End Class