Chinaunix首页 | 论坛 | 博客
  • 博客访问: 838251
  • 博文数量: 253
  • 博客积分: 6891
  • 博客等级: 准将
  • 技术积分: 2502
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-03 11:01
文章分类

全部博文(253)

文章存档

2016年(4)

2013年(3)

2012年(32)

2011年(184)

2010年(30)

分类: Python/Ruby

2011-10-11 10:36:22

  1. #!/usr/bin/perl -w
  2. #
  3. use strict;

  4. my $secret = int(1 + rand 100);
  5. print $secret;
  6. while ( chomp (my $user_input = <STDIN>)){
  7.     if(($user_input eq "quit") || ($user_input eq "exit" ) or ($user_input eq ' ')){
  8.         last;
  9.     }elsif( $user_input > $secret){
  10.         print "the input is too big\n";
  11.         next;
  12.     }elsif( $user_input < $secret){
  13.         print "the input is too small\n";
  14.         next
  15.     }else{
  16.         print "you got it\n";
  17.         last;
  18.     }
  19. }
  20. print "bye\n";
  21. ~
int(1 + rand 100); rand 100 get the number from (0 to 100).



阅读(317) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~