<% option explicit '强制变量声明%>
<html>
<head>
<title>娱乐小游戏</title>
</head>
<body>
<center>
<table border="1" align="center">
<tr><td width="100">玩家</td><td width="100">电脑</td></tr>
<%
dim player,choice,computer,result
player=cint(request.Form("mychoice"))      '先获取玩家的出牌，以防玩家作弊
if player=1 or player=2 or player=3 then 
	randomize timer                         '随机数初始化种子
	computer=int((rnd*3)+1)                 '后获取电脑的随机出牌
	%>
	<tr>
		<td><%printf(player)%></td>
		<td><%printf(computer)%></td>
	</tr>
	<tr align="center">
		<td colspan="2"><%call compet(player,computer)%></td>
	</tr>
<%else%>
	<tr><td colspan="2">愿赌服输，但不可沉迷游戏！</td></tr>
<% end if%>
</table>
<hr>
<form name="form1" action="" method="post" >
玩家请选择：
<input type="radio" name="mychoice" value="1">石头
<input type="radio" name="mychoice" value="2">剪子
<input type="radio" name="mychoice" value="3">布
<input type="submit" value="提交">
</form>
</center>
<%
'下面是子程序,用来定义牌名输出的过程
sub printf(num)
 select case num
	case 1:	choice="石头"
	case 2:	choice="剪子"
	case 3:	choice="布"
  end select
  response.Write choice
end sub
'下面是子程序,用来定义比赛结果输出的过程
sub compet(p,c)
	result=p-c
	select case result
		case 0
		response.write "平手!"
		case -1,2
		response.Write "恭喜你，你赢了!"
		case else 
		response.Write "电脑赢了!"
	end select
end sub
%>
</body>
</html>


