# include <stdio.h>
void main()
{
int i,j,k,n;
printf("水仙花数:\n");
for (n=100; n<1000; n++)
{
i=n/100;
j=(n-i*100)/10;
k=n%10;
if(i*i*i+j*j*j+k*k*k==n)
{
printf("%d ",n);
}
}
}
有关知识:关于余数的求法
# include <stdio.h>
void main()
{
int i,j,k,n;
printf("水仙花数:\n");
for (n=100; n<1000; n++)
{
i=n/100;
j=(n-i*100)/10;
k=n%10;
if(i*i*i+j*j*j+k*k*k==n)
{
printf("%d ",n);
}
}