use diagnostics;
use 5.010;
$num = int(1 + rand 100);
print "input guess number here with 10 times: \n";
while(<STDIN>){
$times++ if $_=~ /\d+/;
if($times > 10 || $_ =~ /^[quit|exit]/i){
print "the real number you was just guessing is $num\n";
print "You've try $times times.\n";
last;
}
print "Too high\n" if $_ > $num;
print "Too low.\n" if $_ < $num;
print "You're so great, you get it with $times times.\n" if $_ == $num;
}
perl版本猜数字
最新推荐文章于 2022-07-21 17:39:04 发布