打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。
public static void main(String[] args) {
int temp,first,second,third,temproraySum;
for(int i = 150;i<999;i++)
{
temp = i;
first = temp /100;
second = (temp%100)/10;
third = temp % 10;
temproraySum = first*first*first+second*second*second+third*third*third;
if(temproraySum == temp)
{
System.out.println(temp);
}
}
}