package printDaffodilNumber;
/*
* 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。(100~1000)
* 比如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。
*/ public class printNumber { static int number1;
static int number2;
static int number3;
//对应个位,十位,百位 public static void main(String[] args) {
// TODO Auto-generated method stub
fun();
} private static void fun(){
for(int i = 100;i<1000;i++){
number1 = i%10;
number2 = i/10%10;
number3 = i/100;
if(number1*number1*number1+number2*number2*number2+number3*number3*number3 == i){
System.out.println(i);
}
}
}
}
输出是:
153
370
371
407