package go50;
/**
*
题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",因为153=1的三次方+5的三次方+3的三次方。
* @author Administrator
*
*/
public class Demo03 {
public static void main(String[] args) {
for (int i = 101; i <1000; i++) {
isSHX(i);
}
}
public static void isSHX(int n){
int a = n/100;
int b = n/10%10;
int c = n%10;
if(a*a*a+b*b*b+c*c*c==n){
System.out.println(n+"是水仙花数");
}
}
}
/**
*
题目:打印出所有的 "水仙花数 ",所谓 "水仙花数 "是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个 "水仙花数 ",因为153=1的三次方+5的三次方+3的三次方。
* @author Administrator
*
*/
public class Demo03 {
public static void main(String[] args) {
for (int i = 101; i <1000; i++) {
isSHX(i);
}
}
public static void isSHX(int n){
int a = n/100;
int b = n/10%10;
int c = n%10;
if(a*a*a+b*b*b+c*c*c==n){
System.out.println(n+"是水仙花数");
}
}
}