/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
intentos = 0 puts"adivinalo" secreto = rand(20) while (intentos < 5) do numero_jugador = Integer(gets.chomp) # teclado intentos = intentos + 1 # intentos += 1 if numero_jugador < secreto puts "tu numero es menor que el secreto" elsif numero_jugador > secreto puts "tu numero es mayor que el secreto" else numero_jugador == secreto break end end if numero_jugador == secreto puts "adivinaste mi numero en #{intentos} intentos" end if numero_jugador != secreto puts "has perdido! mi numero secreto era #{secreto}" end