Commit 08ac2d80 by BellCodeEditor

save project

parent 379c66b4
Showing with 39 additions and 19 deletions
import random
d1=0
d2=0
list=['石头','剪刀','布']
j = random.choice(list)
w=input('玩家出拳(石头/剪刀/布):')
print('玩家出'+w)
print('计算机出'+j)
if w == '石头' and j == '剪刀':
print('玩家赢')
elif w == '石头' and j == '布':
print('计算机赢')
elif w == '剪刀' and j == '石头':
print('计算机赢')
elif w == '剪刀' and j == '布':
print('玩家赢')
elif w == '布' and j == '石头':
print('玩家赢')
elif w == '布' and j == '剪刀':
print('计算机赢')
if w == j:
print('平局')
\ No newline at end of file
n=input('请输入轮数:')
n = int(n)
for i in range(n):
j = random.choice(list)
w=input('玩家出拳(石头/剪刀/布):')
if w != '石头' and w != '剪刀' and w != '布':
print('输入错误')
continue
print('玩家出'+w)
print('计算机出'+j)
if w == '石头' and j == '剪刀':
print('玩家赢')
d1 += 1
elif w == '石头' and j == '布':
print('计算机赢')
d2 += 1
elif w == '剪刀' and j == '石头':
print('计算机赢')
d2 += 1
elif w == '剪刀' and j == '布':
print('玩家赢')
d1 += 1
elif w == '布' and j == '石头':
print('玩家赢')
d1 += 1
elif w == '布' and j == '剪刀':
print('计算机赢')
d2 += 1
if w == j:
print('平局')
if d1 < d2:
print('很遗憾,计算机赢了')
elif d1 == d2:
print('平局了')
else:
print('恭喜,你赢了')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment