求大神指导“输出满足条件n=a!+b!+c!的所有三位数n,其中,a、b、c分别是n的百、十、个位数”
#include <stdio.h>long fact (int n);
int main()
{
int n , a , b , c ;
int sum;
for(n = 100;n <= 1000;n++)
{
a = n / 100;
b = (n - a * 100) % 10;
c = n % 10;
sum = fact(a) + fact(b) + fact(c);
if (sum = n)
printf("%d\n",sum);
}
return 0;
}
long fact (int n)
{
int i;
long result = 1;
for (i = 1;i <= n;i++)
{
result *= i;
}
return result;
}
不知道错在哪儿了