java,for穷举,经典题目:水仙花数


public class t5 {
  //水仙花数
  int a=0;
  for(int g=0;g<10;g++)
  {
   for(int s=0;s<10;s++)
   {
    
    for(int b=1;b<10;b++)
    {
     a=g+s*10+b*100;
 
     if(g*g*g+s*s*s+b*b*b==a)
     {
      System.out.println("a="+a);
      break;
      
     }
     
    }
   }
   
  }
 }
}

posted @ 2016-02-25 16:05  什么玩楞啊,我叫旺仔  阅读(185)  评论(0编辑  收藏  举报