资源简介
# 0 石头,1 剪刀, 2 布
# 0 输,1 赢, 2 平
$a = rand(0,2);
$b = rand(0,2);
$win = 0;
if( $a == $b ) $win = 2;
if( $a == 0 ){
switch ( $b ){
case 1:$win = 1; break;
case 2:$win = 0; break;
}
}
else if( $a == 1 ){
switch ( $b ){
case 0:$win = 0; break;
case 2:$win = 1; break;
}
}
else if ( $a == 2 ) {
switch ( $b ){
case 0:$win = 1; break;
case 1:$win = 0; break;
}
}
$sta = array("石头","剪刀","布");
$str = array("输","赢","平");
echo "A 出的是".$sta[$a]."\n";
echo "B 出的是".$sta[$b]."\n";
echo 'A '.$str[$win].' B了';
代码片段和文件信息
# 0 石头,1 剪刀, 2 布
# 0 输,1 赢, 2 平
$a = rand(02);
$b = rand(02);
$win = 0;
if( $a == $b ) $win = 2;
if( $a == 0 ){
switch ( $b ){
case 1:$win = 1; break;
case 2:$win = 0; break;
}
}
else if( $a == 1 ){
switch ( $b ){
case 0:$win = 0; break;
case 2
- 上一篇:php 微信图片回复代码
- 下一篇:刮刮卡
评论
共有 条评论