Guess the number/With feedback (player): Difference between revisions
Guess the number/With feedback (player) (view source)
Revision as of 08:02, 8 September 2011
, 12 years ago→{{header|Perl}}
No edit summary |
|||
Line 705:
my $max = 99;
print "=>> Think of a number between $min and $max and I'll guess it!\n
Press <ENTER> when are you ready... ";
<STDIN>;
my $x = int(rand $max) + $min;▼
my $tries = 0;
sub question {
my $
print "\n=>> My guess is: $
++$tries;
}
question $
while (1) {
Line 722 ⟶ 725:
if (lc substr($score, 0, 1) eq 'h') {
$min = $
}
elsif (lc substr($score, 0, 1) eq 'l') {
$max = $
}
elsif (lc substr($score, 0, 1) eq 'e') {
Line 735 ⟶ 738:
}
$guess = int(($max + $min) / 2);
question $x;▼
}
</pre>
=={{header|Perl 6}}==
|