求出所有的水仙花数,水仙花数为三位数,并且每位数上的数字的立方的和等于该数本身
。
public class zt {
public static void main(String[] args) {
fun3();
}
private static void fun3() {
for (int i=100;i<=999;i++){
int a=i%10;
int b=i/10%10;
int c=i/100;
if (i==(Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3))){
System.out.println(i+"这是个水仙花数");
}
}
}
截图