- public class XianHua {
- public static void main(String[] args)
- {
- for(int i=100;i<1000;i++)
- {
- if(getSX(i))
- {
- System.out.println(i);
- }
- }
-
- }
- public static boolean getSX(int i)
- {
- int gewei=i%100;
- int shiwei=(i/10)%10;
- int baiwei=i/100;
- int sum=(int)(Math.pow(gewei, 3)+Math.pow(shiwei, 3)+Math.pow(baiwei, 3));
- if(sum==i)
- {
- return true;
- }
- return false;
- }
- }
复制代码 |