import random
rightAnswer = random.randint(1, 100)
small = 1
big = 100
a = 0
b = 0
c = 0
while a < 10 and b < 10 and c < 10:
if a < 10 and b < 10 and c < 10:
answer1 = int(input("请玩家A输入一个整数:"))
if small < answer1 < big:
if answer1 == rightAnswer:
print("游戏者A猜对啦,得+10分,棒棒哒!")
a += 10
else:
if answer1 < rightAnswer:
small = answer1
print("游戏者A得1分,请在", small, "~", big, "猜数。")
a += 1
elif answer1 > rightAnswer:
big = answer1
print("游戏者A得1分,请在", small, "~", big, "猜数。")
a += 1
else:
print("游戏者A吃我一棒槌,得负1分,请在", small, "~", big, "猜数")
a -= 1
if a < 10 and b < 10 and c < 10:
answer2 = int(input("请玩家B输入一个整数:"))
if small < answer2 < big:
if answer2 == rightAnswer:
print("游戏者B猜对啦,得+10分,棒棒哒!")
b += 10
else:
if answer2 < rightAnswer:
small = answer2
print("游戏者B得1分,请在", small, "~", big, "猜数。")
b += 1
elif answer2 > rightAnswer:
big = answer2
print("游戏者B得1分,请在", small, "~", big, "猜数。")
b += 1
else:
print("游戏者B吃我一棒槌,得负1分,请在", small, "~", big, "猜数")
b -= 1
if a < 10 and b < 10 and c < 10:
answer3 = int(input("请玩家C输入一个整数:"))
if small < answer3 < big:
if answer3 == rightAnswer:
print("游戏者C猜对啦,得+10分,棒棒哒!")
c += 10
else:
if answer3 < rightAnswer:
small = answer3
print("游戏者C得1分,请在", small, "~", big, "猜数。")
c += 1
elif answer3 > rightAnswer:
big = answer3
print("游戏者C得1分,请在", small, "~", big, "猜数。")
c += 1
else:
print("游戏者C吃我一棒槌,得负1分,请在", small, "~", big, "猜数")
c -= 3
if a >= 10:
input("游戏者A胜利!")
elif b >= 10:
input("游戏者B胜利!")
elif c >= 10:
input("游戏者C胜利!")
请问还满意么?
如果想要自定义答案的话,可以把最上面两行改成下面的代码↓
rightAnswer = int(input("请输入答案:")
i = 0
while i <= 100:
print(" ")#换行,以免答案泄露
如果您对这个答案很满意,请给一个最佳答案,鼓励我们
|