本帖最后由 王龙彪 于 2012-7-21 23:20 编辑
- public class ShuiXianTest
- {
- public static void main(String[] args)
- {
- int first, second, third;
- for(int start = 100; start < 1000; ++start)
- {
- first = start / 100;//取第 1 位
- second = (start - first * 100) / 10;//取第 2 位
- third = start - first * 100 - second *10;//取第 3 位
-
- if(start == Math.pow(first, 3) + Math.pow(second, 3) + Math.pow(third, 3))
- System.out.println("出现水仙花:" + start);
- }
- }
- }
复制代码 |