百文百鸡 水仙花数 百马百担

package zuoye;

public class zuoye16 {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        
        for (int x = 1; x < 100; x++) {
        for (int y = 1; y < 100; y++) {
        for (int z = 1; z < 100; z++) {
        if (x + y + z == 100 & 5 * x + 3 * y + z / 3 == 100&z%3==0) {
        System.out.println("共有公鸡"+x+"共有母鸡"+y+"共有雏鸡"+z);

                    }
                }
            }
        }

    }
}

水仙花数

package zuoye;

public class zuoye16 {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
    for(int a=1;a<10;a++){
            for(int b=0;b<10;b++){
                for(int c=0;c<10;c++){
                    if (a*a*a+b*b*b+c*c*c==a*100+b*10+c){
                    System.out.println(a*100+b*10+c+"为水仙花数");}
                }
            }
        }
        
    }
}

百马百担

package zuoye;

public class zuoye16 {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        for(int a=1;a<100;a++){
            for(int b=1;b<100;b++){
                for(int c=1;c<100;c++){
                    if (a+b+c==100&a*3+b*2+c*1/2==100&c%2==0){
                    System.out.println("有大马"+a+"有中马"+b+"有小马"+c);}
        }
      }
    }
  }
}
                
            
        
        
    

原文地址:https://www.cnblogs.com/zhanghaozhe8462/p/5106727.html