• 题目:鸡兔同笼
  • 有鸡兔共50个头,共有脚120只
  • 问鸡兔分别有多少

用Java解决

public class jitu{
    public static void main(String[] args) {
        int HEAD = 50;
        int FOOT = 120;
        for (int i = 0; i <= HEAD; i++) {
            int y = HEAD -i;
            if (x*2 + y*4 ==50) {
                System.out.println("鸡:"+ i +"兔:" + y);
            }
        }
    }
}