public class Test04 {
public static void Main (string[] args) {
int x,y,z;//x represents the number of cocks, Y is the number of hens, and Z represents the number of chickens.
for (x=1;x<20;x++) {//Because only 100 money, up to buy 20 cocks, but all buy cocks can not reach 100
for (y=1;y<33;y++) {//Because only 100 money, up to buy 33 cocks, but all buy hens will not reach 100
if (x*5+y*3<=100) {//x*5+y*3 equals money to buy cocks and hens cannot exceed 100
z=3* (100-(x*5+y*3))///Get rid of the money that buys the rooster, the hen is the money that buys the chicken,
The number of chickens bought is equal to the money of the chickens multiplied by 3
if (x+y+z==100) {//The number of all chickens must be equal to 100.
System.out.print ("The number of cocks, hens, chickens are:" +x);
System.out.print ("+y");
System.out.println ("+z");
}
}
}
}
}
}
Hundred-wen buys hundred chicken