打印100-999以内的水仙花数

来源:互联网 发布:手机怎么设置淘宝预售 编辑:程序博客网 时间:2024/05/01 17:06
package hhxy;


/**
 * 打印100-999以内的水仙花数
 * 
 * @author HF
 *
 */
public class DaffodilNumber {
public static void main(String[] args) {
daffodiNumber();
}


public static  void daffodiNumber() {
int a, b, c;
for (int i = 100; i < 999; i++) {
a = i / 100;
b = (i % 100) / 10;
c = i % 10;
if (i == a * a * a + b * b * b + c * c * c) {
                   System.out.println(i);
}
}
}
}
0 0