package practice;
public class study4 {
//题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。123/100=1 123%100=23/10=2 123%10=3
public static void main(String[] args) {
for(int i=100;i<1000;i++){
if(isOrNo(i)){
System.out.println(i+" ");
}
}
}
public static boolean isOrNo(int i){
int one;
int two;
int three;
one=i/100;
two=i%100/10;
three=i%10;
if(one*one*one+two*two*two+three*three*three!=i){
return false;
}
return true;
}
}