公共靜態void main(String[] args) {
int count = 30
int possible num = 1;
for(int I = 4;我& lt=計數;i += 4) {
for(int j = 4;j & lt= count-I;j += 4) {
for(int x = 2;x & lt= count-(j+I);x += 2) {
if (x + j + i == count ) {
system . out . println(" * * * * * * * * * * * *可能"+Possible num++ ":);
system . out . println(" pig = "+(I/4));
system . out . println(" dog = "+(j/4));
system . out . println(" chicken = "+(x/2));
}
for(int y = 2;y & lt= count-(x+j+I);y += 2) {
if (y + x + j + i == count ) {
system . out . println(" * * * * * * * * * * * *可能"+Possible num++ ":);
system . out . println(" pig = "+(I/4));
system . out . println(" dog = "+(j/4));
system . out . println(" chicken = "+(x/2));
system . out . println(" duck = "+(y/2));
}
}
}
}
}
}
}