首页 > 其他 > 详细

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

时间:2016-01-06 13:43:08      阅读:296      评论:0      收藏:0      [点我收藏+]

 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){
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

技术分享

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

原文:http://www.cnblogs.com/haodayikeshu/p/5105098.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!