文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>脚本比赛 (Event 8,猜随机数)

脚本比赛 (Event 8,猜随机数)

时间:2008-03-12  来源:starB6

#!/usr/bin/perl -w
use strict;
 my $data=int(rand(50));
 my $time=0;
 my $biggertime=0;
 my $smallertime=0;
 
 print "please input the data:\n";
 my $input=<STDIN>;
 chomp($input);
  #AARONVOX: #while (1)
#{
    # do something
 #   my $xxx = <>;
 #   goto AARONVOX if $xxx =~ /Hello/;
#}
 AARONVOX:
 while ($input gt $data )
 {
    $biggertime+=1;
    print " the input is too LARGE ! please input again;\n";
      $input=<STDIN>;
     chomp($input);
    goto AARONVOX if $input gt $data;
     goto BARONVOX if $input lt $data;

 
  BARONVOX:
  while ($input lt $data )
 {
    $smallertime+=1;
     print " the input is too small ! please input again;\n";
     $input=<STDIN>;
     chomp($input);
     goto AARONVOX if $input gt $data;
     goto BARONVOX if $input lt $data;
}
 
    $time=$smallertime+$biggertime+1;
    print " the input it : $input,this rand is : $data   ,\n";
   
     print "your input times is $time:\n";
     print " Your input is bigger  has times : $biggertime\n ";
     print "your input is smaller has times :$smallertime\n";
相关阅读 更多 +
排行榜 更多 +
宝宝情商养成宝宝巴士

宝宝情商养成宝宝巴士

休闲益智 下载
燥热手机版

燥热手机版

飞行射击 下载
巨人狙击手安卓版

巨人狙击手安卓版

飞行射击 下载