用VB写一个和电脑猜石头剪刀布的小游戏(要代码)!
请发送到邮箱jiajiatuo122@foxmail.com很急!在线等!做得好的话有加分!!!...
请发送到邮箱jiajiatuo122@foxmail.com 很急!在线等!
做得好的话有加分!!! 展开
做得好的话有加分!!! 展开
3个回答
展开全部
Dim com, you
do Until b=7
com=Int(3 * Rnd)+1
you=inputbox("1代表剪刀,2代表石头,3代表布","请输入一个1-3的数字")
if you = "" then
you=inputbox("1代表剪刀,2代表石头,3代表布","请重新输入一个1-3的数字")
else
if you = false then
exit do
Else
a ="":c=""
coms(com)
yous(int(you))
if int(you) = com then
msgbox "平局!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = 1 or int(you) - com = -2 then
msgbox "恭喜,你赢了!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = -1 or int(you) - com = 2 then
msgbox "真遗憾,你输了!你出的是:"&c&"电脑出的是:"&a
else
msgbox "请输入1-3的数字!"
end if
end if
b=MsgBox ("是否再来一次? ", 4+4096,"系统提示:")
end if
Loop
Function coms(num)
Select Case num
Case "1" a = "剪刀"
Case "2" a = "石头"
Case "3" a = "布"
End Select
End Function
Function yous(num)
Select Case num
Case "1" c = "剪刀"
Case "2" c = "石头"
Case "3" c = "布"
End Select
c=c&"--"
End Function
我给你代码,你百度HI我(我怕代码泄露!!!)
do Until b=7
com=Int(3 * Rnd)+1
you=inputbox("1代表剪刀,2代表石头,3代表布","请输入一个1-3的数字")
if you = "" then
you=inputbox("1代表剪刀,2代表石头,3代表布","请重新输入一个1-3的数字")
else
if you = false then
exit do
Else
a ="":c=""
coms(com)
yous(int(you))
if int(you) = com then
msgbox "平局!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = 1 or int(you) - com = -2 then
msgbox "恭喜,你赢了!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = -1 or int(you) - com = 2 then
msgbox "真遗憾,你输了!你出的是:"&c&"电脑出的是:"&a
else
msgbox "请输入1-3的数字!"
end if
end if
b=MsgBox ("是否再来一次? ", 4+4096,"系统提示:")
end if
Loop
Function coms(num)
Select Case num
Case "1" a = "剪刀"
Case "2" a = "石头"
Case "3" a = "布"
End Select
End Function
Function yous(num)
Select Case num
Case "1" c = "剪刀"
Case "2" c = "石头"
Case "3" c = "布"
End Select
c=c&"--"
End Function
我给你代码,你百度HI我(我怕代码泄露!!!)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Dim com, you
do Until b=7
com=Int(3 * Rnd)+1
you=inputbox("1代表剪刀,2代表石头,3代表布","请输入一个1-3的数字")
if you = "" then
you=inputbox("1代表剪刀,2代表石头,3代表布","请重新输入一个1-3的数字")
else
if you = false then
exit do
Else
a ="":c=""
coms(com)
yous(int(you))
if int(you) = com then
msgbox "平局!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = 1 or int(you) - com = -2 then
msgbox "恭喜,你赢了!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = -1 or int(you) - com = 2 then
msgbox "真遗憾,你输了!你出的是:"&c&"电脑出的是:"&a
else
msgbox "请输入1-3的数字!"
end if
end if
b=MsgBox ("是否再来一次? ", 4+4096,"系统提示:")
end if
Loop
Function coms(num)
Select Case num
Case "1" a = "剪刀"
Case "2" a = "石头"
Case "3" a = "布"
End Select
End Function
Function yous(num)
Select Case num
Case "1" c = "剪刀"
Case "2" c = "石头"
Case "3" c = "布"
End Select
c=c&"--"
End Function
do Until b=7
com=Int(3 * Rnd)+1
you=inputbox("1代表剪刀,2代表石头,3代表布","请输入一个1-3的数字")
if you = "" then
you=inputbox("1代表剪刀,2代表石头,3代表布","请重新输入一个1-3的数字")
else
if you = false then
exit do
Else
a ="":c=""
coms(com)
yous(int(you))
if int(you) = com then
msgbox "平局!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = 1 or int(you) - com = -2 then
msgbox "恭喜,你赢了!你出的是:"&c&"电脑出的是:"&a
elseif int(you) - com = -1 or int(you) - com = 2 then
msgbox "真遗憾,你输了!你出的是:"&c&"电脑出的是:"&a
else
msgbox "请输入1-3的数字!"
end if
end if
b=MsgBox ("是否再来一次? ", 4+4096,"系统提示:")
end if
Loop
Function coms(num)
Select Case num
Case "1" a = "剪刀"
Case "2" a = "石头"
Case "3" a = "布"
End Select
End Function
Function yous(num)
Select Case num
Case "1" c = "剪刀"
Case "2" c = "石头"
Case "3" c = "布"
End Select
c=c&"--"
End Function
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我给你代码,你百度HI我(我怕代码泄露!!!)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询