您的位置:首页 > 其它

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

2016-01-07 16:47 267 查看
public class QiongJu {

public static void main(String[] args) {
//百文百鸡

for(int x=0;x<100;x++){
for(int y=0;y<100;y++){
for(int z=0;z<100;z++){
if(x+y+z==100&&5*x+3*y+z/3==100&&z%3==0){//注意z%3==0 三只雏鸡一文钱 钱数要正好
System.out.println("公鸡  母鸡  雏鸡分别为"+x+"  "+y+"  "+z);
}

}
}

}
//水仙花数
int count=0;
for(int x=1;x<10;x++){
for(int y=0;y<10;y++){
for(int z=0;z<10;z++){
if( x*x*x+y*y*y+z*z*z==x*100+y*10+z){
count++;
System.out.println("第"+count+"水仙花数是:"+x+""+y+""+z);

}
}
}
}
//百马百担
for(int x=0;x<100;x++){
for(int y=0;y<100;y++){
for(int z=0;z<100;z+=2){//注意z+=2 两只小马坨一担  钱数要正好
if(x+y+z==100&&3*x+2*y+0.5*z==100){
System.out.println("大马 中马 小马分别为"+x+" "+y+" "+z);
}
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: