哦 口误 改了应该可以了吧? 我试了可以- public class Test2 {
- public static void main(String [] args)
- {
- ShuiXian s = new ShuiXian();
- s.show();
- }
- static class ShuiXian
- {
- static int a, b, c;
- public static void show()
- {
- for(int m=101;m<1000;m++)
- {
- a =m/100;
- b =m/10%10;
- c =m%10;
- // System.out.println(a+" "+ b +" "+c);
- if (a*100+b*10+c==m && a*a*a + b*b*b + c*c*c==m)
- {
- System.out.println(m+"是一个水仙花数");
- }
- }
- }
- }
- }
复制代码 |