求水仙花的题目
#include<stdio.h>int is_daffodils(int num)
{
int i,f,s,t;
f=num/100;
s=num/10;
t=num%10;
i=f*f*f+s*s*s+t*t*t;
if(i==num)
return 1;
else
return 0;
}
int main()
{
int j=0,n,i;
for(i=1;i<=1000;i++)
{
n=is_daffodils(i);
switch(n)
{
case 1: printf("%d是水仙花\n",i);break;
case 0: printf("%d不是水仙花\n",i);
}
j=j+n;
}
printf("j=%d\n",j);
}