水仙花数

#include
#include
#include
int Judge (int m);
int findArray();

int main ()
{
 int num = 0;
 num=findArray();
 printf("水仙花数个数为%d个。\n",num);
 system("pause");
 return 0;
}

int  findArray()
{
 int i,count = 0;
 for( i = 100 ; i <= 999 ; i++ )
  if(Judge (i))
  {
   count+=1;
   printf("水仙花数是%d\n",i);
  }
 return count;
}

int Judge(int m)
{
 int x,y,z;
 x = m/100;
 y = m%100/10;
 z = m%10;
 if( ( pow(x,3) + pow (y,3) +pow(z,3)) == m)
  return 1;
 else
  return 0;
}

你可能感兴趣的:(原创,C语言)