Title: Print out all "narcissus numbers", the so-called "narcissus number" refers to a three-digit number, and the cubic sum of its digits is equal to the number itself. For example: 153 is a "narcissus number", because 153 = 1 cube + 5 cube + 3 cube.
public class exp3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
for(int i=100;i<1000;i++) {
if(shuixianhua(i)) {
System.out.println(i);
}
}
}
public static boolean shuixianhua(int x) {
int i=0,j=0,k=0;
i=x/100;
j=(x%100)/10;
k=x%10;
if(x==i*i*i+j*j*j+k*k*k)
return true;
else
return false;
}
}