- /*
- 水仙花数
- */
- class FlowerNum1
- {
- public static void main(String[] args)
- {
- int count = 0;
- for(int num = 100;num <= 999; num++)
- {
- int ge = num%10;
- int shi = num%100/10;
- int bai = num/100;
- if((ge*ge*ge + shi*shi*shi + bai*bai*bai) == num)
- {
- count++;
- }
- }
- System.out.println(count);
- }
- }
复制代码 |