Home > Back-end >  Nested loop problem [C language help]
Nested loop problem [C language help]

Time:03-10

Code objective: output "daffodil number", that is, the sum of all digits power three equal to its own three digits, such as 153=1 ^ 3 + 5 + 3 ^ ^ 3 3

Please help to see where there is a problem,

#include
#include
Void main ()
{
Printf (" hw 5.8 \ n ");
Temp (bai, 3)=pow (shi, 3) + + pow pow (ge, 3);
For (double bai=1, shi=0, ge=0;
(100 * * shi bai + 10 + ge) & lt;=999; Bai++)//hundred digit cycle
{
Int temp (bai, 3)=pow (shi, 3) + + pow pow (ge, 3);

For (shi=0, ge=0; Shi<=9; Shi++)//the cycle of ten digits
{
For (ge=0; Ge<=9; Ge++)//single cycle
{
If ((100 + 10 * * bai shi + ge)==temp)
{
Printf (" % d % d % d \ n ", bai, shi, ge);
}
The else printf (" condition does not meet the % d % d % d % d ", bai, shi, ge, temp);

}
Ge=0;

}
Shi=0, ge=0;


}



As word problems lead to layout is not very good, hope understanding,
  • Related