Question 9: Determine whether a number is a "daffodil number"
"Daffodil number" refers to a three-digit number whose cube sum is equal to the number itself.
#include"stdio.h"
void main()
{
int i,j,k,n;
printf("please input the n:\n");
scanf("%d",&n);
printf("\n");
i=n/100;
j=(n-100*i)/10;
k=n%10;
if(i*i*i+j*j*j+k*k*k==n)
printf("the %d is Narcissistic number!\n",n);
else
printf("the %d is not Narcissistic number!\n",n);
}
First find out the digits of the ones, tens, and hundreds, and finally, if the sum of the cubes of the ones, tens, and hundreds is equal to n, output it, otherwise the prompt is not.