Skip to content

Instantly share code, notes, and snippets.

@yuily
Created December 28, 2014 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuily/c808bc7af6ecaa2bc771 to your computer and use it in GitHub Desktop.
Save yuily/c808bc7af6ecaa2bc771 to your computer and use it in GitHub Desktop.
phpでジャンケン 5回勝負をやってみる
<body>
<?php
$player = array('0','5','2','0','5');
$rival = array('5','0','2','5','2');
$win = 0;
$lose = 0;
?>
<?php
for($i = 0,$j = 0;$i < count($player),$j < count($rival);
$i++,$j++){
if(($player[$i] == 0)&&($rival[$j] == 2)){
$win++;}
else if(($player[$i] == 2)&&($rival[$j] == 5)){
$win++;}
else if(($player[$i] == 5)&&($rival[$j] == 0)){
$win++;}
else if(($player[$i] == 0)&&($rival[$j] == 5)){
$lose++;}
else if(($player[$i] == 2)&&($rival[$j] == 0)){
$lose++;}
else (($player[$i] == 5)&&($rival[$j] == 2)){
$lose++;}
}
?>
<?php
print($win.'勝'.$lose.'敗');
?>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment