第六章練習題

Duanhaifeng55發表於2018-04-03

//求男人,女人,小孩,的人數練習題

public static void mathematics() {

int men, women, kids;
for (men = 1; men <= 16; men++) {
for (women = 1; women <= 25; women++) {
for (kids = 1; kids <= 50; kids++) {
if (men + women + kids == 30) {
if (men * 3 + women * 2 + kids == 50) {
System.out.println("男人:" + men + "女人:" + women + "小孩:" + kids);
}
}
}
}
}


}

相關文章