Skip to content

Instantly share code, notes, and snippets.

@jeffersonchaves
Created June 13, 2021 17:55
Show Gist options
  • Save jeffersonchaves/fcbea93c003ef0d67897b982ec62753d to your computer and use it in GitHub Desktop.
Save jeffersonchaves/fcbea93c003ef0d67897b982ec62753d to your computer and use it in GitHub Desktop.
<?php
$lista = [30];
$count = 0;
for ($i = 0; $i < 30; $i++) {
$lista[] = rand(1, 15);
}
print "Digite um numero: ";
$chave = (int) fgets(STDIN);
for ($i = 0; $i < 30; $i++) {
if ($lista[$i] == $chave) {
print "o numero escolhido foi encontrado na posicao: " . $i . "\n";
$count++;
}
}
print "o valor procurado foi encontrado $count vezes.";
//exercucio 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment