This repository has been archived by the owner on Oct 23, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
void start (int min, int max) { | ||
int try_count = 0; | ||
int number = Random.int_range (min, max); | ||
|
||
stdout.printf ("Bienvenido a Adivina el número\n\n"); | ||
stdout.printf ("Tengo pensado un número entre %d y %d, ", min, max); | ||
stdout.printf ("el cual tienes que adivinar. Pero tranquilo, te voy"); | ||
stdout.printf ("a dar algunas pistas\n\n"); | ||
|
||
while (true) { | ||
try_count++; | ||
|
||
stdout.printf ("Intento #%d\n", try_count); | ||
stdout.printf ("Por favor ingrese un número entre %d y %d: ", min, max); | ||
int input = int.parse (stdin.read_line ()); | ||
|
||
if (number == input) { | ||
stdout.printf ("¡Ganador! Lo hiciste en %d intentos\n", try_count); | ||
break; | ||
} else { | ||
stdout.printf ("Error, el número es %s que %d.\n", | ||
number > input ? "mayor" : "menor", input); | ||
} | ||
} | ||
} | ||
static int main (string[] args){ | ||
stdout.printf("Ingrese el mínimo: "); | ||
int min = int.parse(stdin.read_line()); | ||
stdout.printf("Ingrese el máximo: "); | ||
int max = int.parse(stdin.read_line()); | ||
start(min, max); | ||
return 0; | ||
|
||
} |