打印所有的水仙花数java
时间: 2023-05-29 21:03:07 浏览: 79
打印水仙花数JAVA代码
public class NarcissisticNumbers {
public static void main(String[] args) {
for (int i = 100; i < 1000; i++) {
int a = i / 100;
int b = i / 10 % 10;
int c = i % 10;
if (i == a * a * a + b * b * b + c * c * c) {
System.out.println(i);
}
}
}
}
阅读全文