|
球球大佬们救救我,我花了三四个小时都没有写出来,不知道是思路错了还是细节没有处理到位。求指导!!
最好是在我这个代码基础上面更改,这样我可以更深刻的领悟到我错误的点。谢谢谢谢。(ps:我还没有写到计算次数,因为前面就卡住了)
a = int(input('请输入左区间:'))
b = int(input('请输入右区间:'))
import random
c = random.choice(range(a,b))
print(c)
s1 = '小了'
s2 = '大了'
s3 = '对了'
while True:
d = str(input('电脑的答案:'))
tag = True
if d == s1:
e = random.choice(range(c, b))
print(e)
while tag:
d = str(input('电脑的答案:'))
if d == s1:
f = random.choice(range(e, c))
print(f)
e = f
tag=False
elif d == s2:
f = random.choice(range(c, e))
print(f)
e = f
tag=False
else:
break
elif d == s2:
e = random.choice(range(a, c))
print(e)
while tag:
d = str(input('电脑的答案:'))
if d == s1:
f = random.choice(range(e, c))
print(f)
e = f
tag=False
elif d == s2:
f = random.choice(range(a, e))
print(f)
e = f
tag=False
else:
break
else:
break |
|