/* if an n is a positive integer is equal to its n number of n to the power and the number of known as n the power since the number, the power design for 3 ~ 6 from number,
* * output format requirements: "% d bits from the exponential are:" "% ld \ t" "\ n" (after each newline)
Application example are as follows:
3 since the power number: 153 370 371 407
4 since the exponential are: 1634 8208 9474
5 the power number: 54748 92727 93084
Six since the power number: 548834 */
# include
# include
Int HHH (int n)
{
Long a [10], I, j, x, y, t, sum=0;
X=pow (10, n - 1);
Y=pow (10, n);
For (I=x; i{
T=I;
for(j=0; J{
A [j]=t % 10;
T/t=10;
}
for(j=0; J{
Sum +=pow (a [j], n);
}
If (sum==I)
{
Printf (" % ld \ t ", sum);
}
Sum=0;
}
}
Int main (void)
{
int i;
For (I=3; i<=6; I++)
{
Printf (" % d a since the exponential are: ", I);
HHH (I);
printf("\n");
}
}
The running result is like this:
CodePudding user response:
Didn't see you run, I run, there is no problem:The int HHH () function is slightly changed:
int HHH (int n)
{
Long a [10], I, j, x, y, t, sum;
X=pow (10, n - 1);
Y=pow (10, n);
For (I=x; i{
T=I;
Sum=0;//the sum initialization here
for(j=0; J{
A [j]=t % 10;
T/t=10;
}
for(j=0; J{
Sum +=pow (a [j], n);
}
If (sum==I)
{
Printf (" % ld \ t ", sum);//"% ld \ t" join a space in between.
}
}
}