本程序以较为简单的方法来实现,代码如下:
'''
鸡兔同笼,头35个,脚94只,问鸡、兔各多少?
'''
XrabFeet = 35 * 4 #假设笼子里都是兔子,一共有多少只脚
ChickenFeet = XrabFeet - 94
chickens = ChickenFeet / 2
rabbits = 35 - chickens
print(f"The number of the chickens is: {int(chickens)}.")
print(f"The number of the rabbits is: {int(rabbits)}")
如果有更好的方法,欢迎大家关注我并私聊我,一起交流,共同进步。