当前位置 博文首页 > 程序员A的博客:水仙花数Java

    程序员A的博客:水仙花数Java

    作者:[db:作者] 时间:2021-06-14 09:37

    <pre name="code" class="java"><pre name="code" class="java"><pre name="code" class="java">public class test1{
        public static void main(String[] args)
    		{
            
          int x,y,m,z,i=0;
    	  int [] a=new int[8];
    	  
          for(m=100;m<1000;m++)
            {
    		 x=m/100;
            y=m/10-x*10;
            z=m%10;
            if(x*100+y*10+z==x*x*x+y*y*y+z*z*z )
            {
              
              a[i]=m;
              i++;
            }
            
            }
          for(x=0;x<i;x++)
            System.out.println(a[x]);
        }
    	/*
    153
    370
    371
    407
    请按任意键继续. . .
    
    
    	*/
    }