Created
December 28, 2014 14:42
-
-
Save yuily/c808bc7af6ecaa2bc771 to your computer and use it in GitHub Desktop.
phpでジャンケン 5回勝負をやってみる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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