perl版本猜数字
发布时间:2020-12-16 00:21:33 所属栏目:大数据 来源:网络整理
导读: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 $numn";print "
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 $numn"; print "You've try $times times.n"; last; } print "Too highn" if $_ > $num; print "Too low.n" if $_ < $num; print "You're so great,you get it with $times times.n" if $_ == $num; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |