Home > Back-end >  C, daffodil number, take relevant prototype function:
C, daffodil number, take relevant prototype function:

Time:03-27

Int * calc (int result [], int the begin=100, int the end=1000). For leaders to solve the

CodePudding user response:

Reference:
 # include 

Int * calc (int result [], int the begin=100, int the end=1000).

Int main ()
{
Int result [10]={0}, * a;
A=calc (result);
for (int i=0; i<10; I++)
If (a [I]!=0)
Printf (" % d ", a [I]);

return 0;
}

Int * calc (int result [], int the begin, int the end)
{
Int I, n, temp, sum, k=0;
For (I=begin; iTemp=I; sum=0;
While (temp) {
N=temp % 10;
The sum +=n * n * n.
Temp/=10;
}
If (sum==I) result [k++]=I;
}
return result;
}