Created
December 27, 2019 15:11
-
-
Save franciscopessoa/09616285d757f7f4b28b4bd8b85235fd to your computer and use it in GitHub Desktop.
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
#!/usr/bin/php | |
<?php | |
$stdin = fopen('php://stdin', 'r'); | |
echo "Entre com o número de apostas desejadas: " . "\n"; | |
$nrApostas = trim(fgets($stdin)); | |
if (!is_numeric($nrApostas)) { | |
echo "Número inválido"."\n"; | |
} else { | |
echo "Agora informe o número de dígitos das apostas: " . "\n"; | |
$nrDigitos = trim(fgets($stdin)); | |
if (!is_numeric($nrDigitos)) { | |
echo "Valor inválido" . "\n"; | |
} else if ($nrDigitos < 6 or $nrDigitos > 15) { | |
echo "São permitidas apostas apenas de números que estejam entre 6 e 15" . "\n"; | |
} else { | |
$count = 0; | |
$aposta = []; | |
while ($count < $nrApostas) { | |
for ($i = 1; $i <= $nrDigitos; $i++) { | |
$numero = rand(1, 60); | |
while (in_array($numero, $aposta)) { | |
$numero = rand(1, 60); | |
} | |
$aposta[] = $numero; | |
} | |
print_r(implode(',', $aposta) . "\n"); | |
$aposta = []; | |
$count++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment