What is the Narcissus Number?
The "daffodil number" refers to a 3-digit number in which the sum of the cubes of the digits is equal to the number itself.
Implementation code:
#includeint main() { int a,b,c; for(int i=100;i<=999;i++) { a=i/100; //百位数 b=(i/10)%10; //十位数 c=i%10; //个位数 if(a*a*a+b*b*b+c*c*c==i) printf("%d\n",i); } return 0; }
The output results are as follows:
Recommended tutorial:c language tutorial
The above is the detailed content of C language implements output of all narcissus numbers. For more information, please follow other related articles on the PHP Chinese website!