题解 | #变种水仙花#
变种水仙花
http://www.nowcoder.com/practice/c178e3f5cc4641dfbc8b020ae79e2b71
include<stdio.h>
int main()
{
//int a = 0;
int n = 10000;
int b = 0;
//int sum = 0;
//scanf("%d", a);
while (n <= 99999 && n >= 10000)
{
int sum = 0; //犯了一个大错误,开始将sum放在外面,结果没清0
for (b = 10; n/ b != 0; b = b * 10)
{
sum += (n / b)*(n%b);
}
if (sum == n)
{
printf("%d ", n);
n++;
}
else
{
n++;
}
}
return 0;
}