28,391
社区成员
发帖
与我相关
我的任务
分享
<%
Function ComputerChoose()
Dim RandomNum
Dim choice
choice=array("S","J","B")
Randomize
RandomNum=int(rnd*3)
ComputerChoose=choice(RandomNum)
End Function
sub DetermineWinner(playerChoice,computerChoice)
dim str
str=trim(playerChoice)&trim(computerChoice)
select case str
case "SS":
response.write" <font color=red> 石头 </font> VS <font color=blue>石头 </font><br>"
response.write"我们平手了"
case "SJ":
response.write" <font color= red > 石头 </font> VS <font color=blue> 剪子 </font><br>"
response.write"恭喜你,你赢了"
case "SB":
response.write" <font color=red> 石头 </font> VS <font color=blue>布 </font> <br>"
response.write"哈哈哈,你输了"
case "JS":
response.write" <font color=red> 剪子 </font> VS <font color=blue>石头</font> <br>"
response.write"哈哈哈,你输了"
case "JJ":
response.write" <font color=red>剪子 </font> VS <font color=blue>剪子 </font> <br>"
response.write"我们平手了"
case "JB":
response.write" <font color=red>剪子 </font> VS <font color=blue> 布 </font><br>"
response.write"恭喜你,你赢了"
case "BS":
response.write " <font color=red>布 </font> VS <font color=blue> 石头 </font> </br>"
response.write"恭喜你,你赢了"
case "BJ":
response.write" <font color=red> 布 </font> VS <font color=blue>剪子 </font> <br>"
response.write"哈哈哈,你输了"
case "BB":
response.write" <font color=red> 布 </font> VS <font color=blue>布 </font> <br>"
response.write"我们平手了"
case else response.write"出错了"&str
END SELECT
End sub
%>
<html>
<title>石头、剪子、布小游戏 </title>
<body>
<center>
玩家 <font color="#FFFFFF">--------- </font>计算机 <br>
<%
dim player
dim computer
player=request("choice")
if player="S" or player="J" or player="B" then
computer=ComputerChoose()
call DetermineWinner(player,computer)
end if
%>
<hr>
请做出你的选择:
<form action="11.asp" method="post">
<input type="radio" name="choice" value="S" >石头 <br>
<input type="radio" name="choice" value="J" >剪子 <br>
<input type="radio" name="choice" value="B" >布 <br >
<input type="submit" value="开战" >
</form>
</center>
</body>
</html>