好的,这是一个用 Python 解决鸡兔同笼问题的代码:
def solve(heads, legs):
for chicken in range(heads + 1):
rabbit = heads - chicken
if 2 * chicken + 4 * rabbit == legs:
return (chicken, rabbit)
return None
heads = int(input("请输入头数:"))
legs = int(input("请输入腿数:"))
result = solve(h