輸出所有的水仙花數,把謂水仙花數是指一個數3位數,其各各位數字立方和等於其本身,
例如: 153 = 1*1*1 + 3*3*3 + 5*5*5
// 六行代碼解決
public static void main(String[] args) throws ParseException {
for(int a = 100;a<1000;a++) {int i = (int) Math.ceil(a/100);
int j = (int) Math.ceil(((int) a%100)/10);
int k = a%100%10;
if (a == Math.pow(i, 3) + Math.pow(j, 3) + Math.pow(k, 3)) {
System.out.println(a);
}
}
}