Problem Description Print all daffodil numbers between 100 and 999. The so-called daffodil number refers to an integer that satisfies the cubic sum of its digits as the number itself, for example 153 = 1 ^ 3 + 5 ^ 3 + 3 ^ 3 . sample input A sample input that meets the requirements of the question. example: without Sample output 153 xxx xxx
AC code:
1 #include <stdio.h> 2 #define X3(x) ((x)*(x)*(x)) /*立方*/ 3 4 int main(void) 5 { 6 int i; 7 int a,b,c; 8 for (i = 100 ; i <= 999 ; i ++) 9 { 10 a = i/100; 11 b = i/10%10; 12 c = i%10; 13 if (i == X3(a)+X3(b)+X3(c)) 14 { 15 printf("%d\n",i); 16 } 17 } 18 return 0; 19 }