python编程,鸡兔同笼
发布网友
发布时间:2022-04-25 15:13
我来回答
共1个回答
热心网友
时间:2022-04-19 00:01
def candr(head, foot):
rabit = 1
while 1:
foots = 2 * (head + rabit)
if foots == foot:
if head - rabit > 0:
print('兔={0} 鸡={1} '.format(rabit, head - rabit))
else:
print("Data Error")
break
elif foots > foot:
print("Data Error")
break
else:
rabit += 1