1#include <stdio.h>2#include <math.h>3 4 5 intMain ()6 {7 /*number of three daffodils8 Concept: If three-digit ABC satisfies abc=a^3+b^3+c^3, it is called three-bit narcissus number. For example 153=1^3+5^3+3^3, so 153 is the number of daffodils9 Ten implementation steps: One 1. Enter two numbers, indicating the interval [a, a], since the solution is three-bit narcissus number, so a>=100,b<=999, and B>a A 2. Implement the algorithm, set NUM, break down the hundred, 10 bits, and then add each three times to see if and equal to Num - 3. Output Narcissus number - the here we need to introduce a method pow (int x,int y) to include the MATH.H header file - Example: - double x=2.0,y=3.0; - printf ("The%lf of the%LF is:%lf\n", X,y,pow (x, y)); + Print out: 2.000000 of 3 times is: 8.000000 - */ + A //1 Statement hundred 10 digit digit at intBai,shi,ge; - intnum; - - //2 Implementation Algorithm - for(num= -; num<=999; num++) - { in //2.1 Hundred, 10 bits, single digit decomposition -Bai = num/ -; toShi = num/Ten%Ten; +GE = num%Ten; - //2.2 Judgment Algorithm the if(num = Pow (bai,3) +pow (Shi,3) +pow (GE,3)) * { $printf"%d\n", num);Panax Notoginseng } - } the + return 0; A}
Printing results:
The concept of the number of daffodils added:
Narcissus number refers to an n-digit number (n≥3), and the sum of the number of its digits on each bit is equal to its own.
Number of three daffodils