打印水仙花数

1.100~1000 水仙花数

    public static void main(String[] args) {
        int i, x, y, z;
        for (i = 100; i < 1000; i++) {
            x = i % 10;
            y = i / 10 % 10;
            z = i / 100 % 10;

            if (i == (x * x * x + y * y * y + z * z * z)) {
                System.out.println(i + "是水仙花数");
            }
        }
    }

image

posted @ 2022-03-23 16:38  ___sunsets  阅读(19)  评论(0)    收藏  举报