public class Test05 {
public static void main(String[] args) {
/*
* 鸡兔同笼,共有头48个,脚132只,求鸡和兔各有多少只?
* 鸡设为x 兔设为y
* x+y = 48 鸡头加兔头是48个头
* 2x +4y = 132 鸡脚加兔腿总共是132个退
* x = 48-y
* 96 -2y + 4y = 132
* 96 + 2y = 132
* 2y = 36
* y = 18;
* x = 48-18 = 30
*/
//鸡可能的数量
for(int i =0;i<=48;i++) {
//兔子可能存在的数量
for(int j =0;j<=48-i;j++) {
//x+y = 48 2x +4y = 132
if(i*2 + j*4 == 132 && i+j==48) {
System.out.println("鸡:"+i);
System.out.println("兔子:"+(j));
}
}
}
}
}