CodePudding user response:
This function take stepsOne is to calculate the number of each each, can use % 10 to get
Then add each cubic want to determine whether is equal to the number of
Then put these steps into a cycle, the cycle running from 100 to 1000,
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;
}