假设鸡兔脚总攻94,鸡兔总共35只
public class Test {
public static void main(String[] args) {
int x,y; //x:鸡 y:兔
for(x=0;x<=35;x++) { //遍历鸡的只数x
for(y=0;y<=35;y++){ //兔的只数等于y
if(2*x+4*y==94 && x+y==35) { //如果鸡和兔的脚总数是94,x+y==35
System.out.println("鸡"+x+"只,兔"+y+"只");
}
}
}
}
}
鸡23只,兔12只