Case: Hundreds of Money and Hundreds of Chickens

Case: Hundreds of Money and Hundreds of Chickens

//需求:有鸡翁、鸡母、鸡雏共100只 ,其中鸡翁一值钱五,鸡母一值钱三,鸡雏三值钱一。百钱买百鸡,问鸡翁、鸡母、鸡雏各几何?
public class HelloWorld{
    
    
    public static void main(String[] args){
    
    
        for(int w = 0;w <= 20;w++){
    
    
            for(int m = 0; m <= 33;m++){
    
    
                int c = 100 - w - m;
                if(c%3 == 0 && 5*w + 3*m + c/3 == 100){
    
    
                    System.out.println(w+","+m+","+c);
                }
            }
        }
    }
}

Guess you like

Origin blog.csdn.net/taoyingle/article/details/115262271