“`
package yc;
public class baiqianmaibaiji
{
public static void main (String []
args)
{
for (int x = 0; x <= 19; x++)
{
for (int y = 0; y <= 33; y++)
{
int z = 100 - x - y;
if((x * 5 + y * 3 + z / 3 == 100 ) && z % 3 == 0)
{
System.out.println(“可买鸡翁只数:” + x);
System.out.println(“可买鸡母只数:” + y);
System.out.println(“可买鸡雏只数:” + z);
}
}
}
}
}
“`
总结:用了一个for循环