100元怎麼買100個蛋,雞蛋1毛一個,鴨蛋3元一個,鵝蛋6元一個
public class Egg{
public static void main(String[] args){
int chicken=0,duck=0,goose=0;
for(int i=0;i<100;i++){
chicken = i;
for(int j=0;j<100;j++){
duck = j;
goose = 100-duck-chicken;
if(chicken+duck*30+goose*60==1000&&chicken>0&&duck>0&&goose>0){
System.out.println("雞:"+chicken+" 鴨:"+duck+" 鵝:"+goose);
}
}
}
}
}