编辑代码

#include <stdio.h>

int IsNarcissisticNum(int x);
int main () {
  for (int i = 100; i < 1000; i++) {
    if (IsNarcissisticNum(i)) {
      printf("%d 是水仙花数\n", i);
    }
  }
  return 0;
}

int IsNarcissisticNum(int x) {
  int a = x / 100;
  int b = x / 10 - 10 * a;
  int c = x % 10;
  if (a * a * a + b * b * b + c * c * c == x) {
    return 1;
  } else {
    return 0;
  }
}