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);
}
}
}
----------------解决方案--------------------------------------------------------
----------------解决方案--------------------------------------------------------