首页 > 代码库 > 百钱百鸡

百钱百鸡

package 课上程序/** *  * 百钱百鸡问题 * @author 王启文 *  */public class baiqianbaiji {    public static void main(String[] args) {        int a = 1, b = 1, c = 1;        for (a = 0; a <= 20; a++) {            for (b = 0; b < 34; b++) {                c = (100 - 5 * a - 3 * b) * 3;                if (a + b + c == 100) {                    System.out.printf("公鸡、母鸡、小鸡数量分别为:%d %d %d\n", a, b, c);                }            }        }    }}

 

百钱百鸡