【Java】求1~1000中所有的水仙花数

在这里插入代码片
```public class test {
 private static void flower() {
        for (int i = 100; i < 1000; i++) {
            int a = i / 100;
            int b = (i / 10) % 10;
            int c = i % 10;
            if(i==Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3)) {
                System.out.println(i);
            }
        }
    }
    public static void main(String[] args) {
        flower();
    }
}


猜你喜欢

转载自blog.csdn.net/qq_44771577/article/details/88784497