49只脚分别是兔子和鸡的脚问多少只兔子多少字鸡

来源:百度知道 编辑:UC知道 时间:2024/05/25 09:38:14
打算

兔子 1 2 3 4 5 6 7 8 9 10 11 12
鸡 45 41 37 33 29 25 21 17 13 9 5 1
你一定知道金鸡独立吧!一只鸡一只脚,一只兔子四只脚。

没有合适的解
下面用一个java程序来运行
public class FootEx
{
----public static void main(String args[])
----{
--------int count = 0;
--------int foot = 49;

--------for(int i = 1; i <= foot / 4; i++)
--------{
------------for(int j = 1; j <= foot / 2; j++)
------------{
----------------if(i * 4 + j * 2 == foot)
----------------{
--------------------System.out.println(++count + "\t兔子的数量是: " + i + "\t\t鸡的数量是: " + j);
----------------}
------------}
--------}

--------if(count == 0)
--------{
------------System.out.println("没有合适的数量满足条件!!!");
--------}
--------else
--------{
------------System.out.println("有 " + count + " 组合适的数量满足条件!!!");
--------}
----}
}
--