百钱买白鸡问题

来源:互联网 发布:三维b超单数据怎么看 编辑:程序博客网 时间:2024/06/07 01:09
public class Demo {    /**     * 百钱买百鸡     * @param args     */    public static void main(String[] args) {        int z = 0;        for (int x = 0; x <= 20; x++) {            for (int y = 0; y <= 33; y++) {                z = 100 - x - y;                if (z % 3 == 0 && 5 * x + 3 * y + z / 3 == 100) {                    System.out.println("公鸡数:" + x + "\t" + "母鸡数" + y + "\t" + "雏鸡" + z);                }            }        }    }}

公鸡数:0 母鸡数25 雏鸡75
公鸡数:4 母鸡数18 雏鸡78
公鸡数:8 母鸡数11 雏鸡81
公鸡数:12 母鸡数4 雏鸡84

0 0
原创粉丝点击