答案:<%
'*********************************************
' THIS IS A SIMPLE GAME OF ROCK SCISSORS PAPER
' FEEL FREE TO DO WHATEVER YOU LIKE WITH THIS
' SCRIPT! -IAN S. CARROLL
'*********************************************
'*********************************************
' THIS FUNCTION GENERATES A RANDOM NUMBER
'*********************************************
Function computerChooses()
Dim randomNum
Dim choice
randomize
randomNum = int(rnd*15)+1
If randomNum = 1 OR randomNum = 3 OR randomNum = 7 OR randomNum = 8 OR randomNum = 15 OR randomNum = 12 Then
choice = "R"
ElseIf randomNum = 2 OR randomNum = 6 OR randomNum = 11 OR randomNum = 13 Then
choice = "S"
Else
choice = "P"
End If
computerChooses = choice
End Function
'*********************************************
' THIS FUNCTION SIMPLY DETERMINES THE WINNER
' OF THE GAME
'*********************************************
Sub determineWinner(playerChoice, computerChoice)
Const Rock = "R"
Const Scissor = "S"
Const Paper = "P"
Dim tempPlayer, tempComputer
If playerChoice = Rock Then
If computerChoice = Scissor Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/rock_beats_scissors.gif"><BR>
Your ROCK crushed the computer's SCISSORS!"</CENTER>
<%
End If
ElseIf playerChoice = Scissor Then
If computerChoice = Paper Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/scissors_beats_易做图.gif"><BR>
Your SCISSORS cut up the computer's PAPER!</CENTER>
<%
End If
ElseIf playerChoice = Paper Then
If computerChoice = Rock Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/易做图_beats_rock.gif"><BR>
Your PAPER stumped the computer's ROCK!</CENTER>
<%
End If
ElseIf playerChoice = computerChoice Then
%>
<p><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/tie.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
If computerChoice = Rock Then
If playerChoice = Scissor Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/rock_beats_scissors.gif"><BR>
The computer's ROCK crushed your SCISSORS!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/tie.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Scissor Then
If playerChoice = Paper Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/scissors_beats_易做图.gif"><BR>
The computer's SCISSOR cut up your PAPER!</CENTER>
<%
ElseIf playerChoice = computerChoice Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/tie.gif"><BR>
We seem to have a tie!</CENTER>
<%
End If
ElseIf computerChoice = Paper Then
If playerChoice = Rock Then
%>
<P><CENTER>
<IMG SRC=http://old.zzzyk.com/article/Article/"images/易做图_beats_rock.gif"><BR>
&
上一个:用文本+ASP打造新闻发布系统。几点补充
下一个:产生随机密码的函数