public class FlowerTest {
public static void main(String[] args){
int a,a1,a2,a3;
for(a=100;a<=999;a++){//循环遍历所有可能的三位数
a1=a%10;//个位
a2=a/10%10;//十位
a3=a/100;//百位
if(a==Math.pow(a1,3)+Math.pow(a2,3)+Math.pow(a3,3)){//调用数学方法来进行立方运算
System.out.printf("水仙花数为 %d",a);//打印所有满足条件的水仙花数
System.out.println();//换行
}
}
}
}
public class FlowerTest {
public static void main(String[] args){
int a,a1,a2,a3;
for(a=100;a<=999;a++){//循环遍历所有可能的三位数
a1=a%10;//个位
a2=a/10%10;//十位
a3=a/100;//百位
if(a==Math.pow(a1,3)+Math.pow(a2,3)+Math.pow(a3,3)){//调用数学方法来进行立方运算
System.out.printf("水仙花数为 %d",a);//打印所有满足条件的水仙花数
System.out.println();//换行
}
}
}
}