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

 1  public class QiongJu {
 2 
 3     
 4     public static void main(String[] args) {
 5         //百文百鸡
 6     
 7     
 8         for(int x=0;x<100;x++){
 9                for(int y=0;y<100;y++){
10                   for(int z=0;z<100;z++){
11                       if(x+y+z==100&&5*x+3*y+z/3==100&&z%3==0){//注意z%3==0 三只雏鸡一文钱 钱数要正好
12                           System.out.println("公鸡  母鸡  雏鸡分别为"+x+"  "+y+"  "+z);      
13                     }
14                       
15                 }
16                }
17         
18         }
19         //水仙花数
20         int count=0;
21         for(int x=1;x<10;x++){
22                for(int y=0;y<10;y++){    
23                    for(int z=0;z<10;z++){
24                        if( x*x*x+y*y*y+z*z*z==x*100+y*10+z){
25                            count++;
26                            System.out.println("第"+count+"水仙花数是:"+x+""+y+""+z);
27                                
28                                }
29                            }
30                        }
31                 }
32         //百马百担
33         for(int x=0;x<100;x++){
34                for(int y=0;y<100;y++){
35                   for(int z=0;z<100;z+=2){//注意z+=2 两只小马坨一担  钱数要正好
36             if(x+y+z==100&&3*x+2*y+0.5*z==100){
37               System.out.println("大马 中马 小马分别为"+x+" "+y+" "+z);
38                           }
39                       }

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