2016/1/6 百文百鸡 水仙花数 百马百担


 1 public class QiongJu {
 2 
 3     
 4     public static void main(String[] args) {
 5         //百文百鸡
 6         for(int x=1;x<100;x++){
 7                for(int y=1;y<100;y++){
 8                   for(int z=1;z<100;z++){
 9                       if(x+y+z==100&&5*x+3*y+z/3==100&&z%3==0){
10                           System.out.println("公鸡  母鸡  雏鸡分别为"+x+"  "+y+"  "+z);
11                        }
12             
13                     }
14                   }
15         
16                 }
17         }
18    }
19     

 1 int count=0;
 2         for(int x=1;x<10;x++){
 3                for(int y=0;y<10;y++){
 4                    for(int z=0;z<10;z++){
 5                        if( x*x*x+y*y*y+z*z*z==x*100+y*10+z){
 6                            count++;
 7                            System.out.println("第"+count+"水仙花数是:"+x+""+y+""+z);
 8                                
 9                                }
10                        }
11                    }
12             }
View Code


1 for(int x=1;x<100;x++){
2                for(int y=1;y<100;y++){
3                   for(int z=1;z<100;z++){
4             if(x+y+z==100&&3*x+2*y+0.5*z==100){
5               System.out.println("大马 中马 小马分别为"+x+" "+y+" "+z);
6                           }
7                       }
8                   }
9                }
View Code

原文地址:https://www.cnblogs.com/haodayikeshu/p/5105098.html