# include <stdio.h>
void main()
{ int m, a, b, c; m = 100; while (m <= 999) { a = m%10; c = m/100; b = (m - c * 100) / 10; if (m == c * c * c + b * b * b + a * a * a) printf("%d ", m); m ++; } printf("\n");
}
是楼主 赋值 的次序错了,,,
用循环做
#include <stdio.h>
int main ()
{ int a, b, c, number; printf ("水仙花数为:"); for (number = 100; number < 1000; number++) { a = number / 100; b = number /10 % 10; c = number % 10;
if (a * a * a + b * b * b + c * c * c == number) { printf ("%d \n", number); } } return 0;
}