当前位置: 代码迷 >> Java Web开发 >> java求求
  详细解决方案

java求求

热度:230   发布时间:2008-11-04 21:28:58.0
java求求
公鸡3元1只 ,母鸡5元一只 ,小鸡3只1元
用100元能组成100只鸡
搜索更多相关主题的帖子: java  

----------------解决方案--------------------------------------------------------
int numCock=0, numHen=0,numChick=0;
System.out.println("Cock Hen Chick");

for(numCock=1;numCock<20;numCock++)
{

for(numChick=3;numChick<100;numChick=numChick+3)
{
numHen=100-numCock-numChick;
if (((numHen*3+numCock*5+numChick/3)==100)&&(numHen>0))
System.out.println(numCock+" "+numHen+" "+numChick);
}
}
}
----------------解决方案--------------------------------------------------------

----------------解决方案--------------------------------------------------------
  相关解决方案