打印水仙花数。水仙花数是一个三位数,其各位数字的立方和与原数相等。
输出格式:
按递增顺序输出所有水仙花数,每个数输出占5列。
输出样例:
153 370 371 407
#include<stdio.h>
int main()
{
int a,b,c,x=100;
for(x=100;x<=999;x++)
{
a=x/100;
b=(x/10)%10;
c=(x%10);
if(x==a*a*a+b*b*b+c*c*c)
printf("%5d",x);
}
return 0;
}