Chinaunix首页 | 论坛 | 博客
  • 博客访问: 12037
  • 博文数量: 2
  • 博客积分: 150
  • 博客等级: 入伍新兵
  • 技术积分: 40
  • 用 户 组: 普通用户
  • 注册时间: 2006-02-08 12:54
文章分类
文章存档

2008年(2)

我的朋友
最近访客

发布时间:2008-10-10 11:45:17

......【阅读全文】

阅读(988) | 评论(0) | 转发(0)

发布时间:2008-10-10 11:42:33

......【阅读全文】

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

chinaunix网友2008-10-10 11:37

#!/usr/bin/perl use strict; use warnings; our ($You, $Me, $Draw) = (0,0,0); my @options = ("rock", "paper", "scissors"); my($my_turn, $your_turn); PrintIntro(); while(1) { $my_turn = MyGo(); $your_turn = YourGo()-1; print "Me: $options[$my_turn], You: $options[$your_turn] -- "; Results($my_turn, $your_turn); PrintScore($You, $Me, $Draw); last unless Continue(); } sub PrintIntro { print "\nRock, paper, scissors\n"; print "---------------------\n\n"; print "Rock beats scissors,\n"; print "Scissors beats paper, \n"; print "Paper beats rock.\n\n"; } sub MyGo { return int(rand(3)); } sub YourGo { my $Turn = 0; print "Enter 1-rock, 2-paper, 3-scissors\n"; chomp($Turn = ); while(($Turn < 1) || ($Turn > 3)) { print "Enter 1-rock, 2-paper, 3-scissors\n"; chomp($Turn = ); } return $Turn; } sub PrintScore { print "You scored $You, I scored $Me with $Draw draws.\n"; if($You > $Me) { print "You are winning.\n"; } if($You < $Me) { print "I am winning.\n"; } print "\n\n"; } sub Results { my($my, $your) = @_; my $Test = $my - $your; if($Test == 0) { $Draw++; print " Draw.\n"; } elsif ($Test == -1) { $You++; print " You won.\n"; } elsif ($Test == 2) { $You++; print " You won.\n"; } else { $Me++; print " I won.\n"; } } sub Continue { print "\nAnother game?(y/n): "; my $answer; while (1) { $answer = ; chomp $answer; last if (lc $answer eq 'y') || (lc $answer eq 'n'); } return $answer eq 'y'; }

回复 |  删除 |  举报

chinaunix网友2006-05-19 13:24

小胖,可以到zhaoyuttlee.bolgcn.com找我!!

回复 |  删除 |  举报

chinaunix网友2006-05-04 11:21

哈哈~~~~我过来拉,你要请我吃饭

回复 |  删除 |  举报

chinaunix网友2006-05-02 16:01

小胖.有空來坐坐!!!!

回复 |  删除 |  举报

chinaunix网友2006-04-30 16:05

暈ing****************************

回复 |  删除 |  举报
留言热议
请登录后留言。

登录 注册