问题
输出所有的“水仙花数”。所谓“水仙花数”是指一个3位数,其各位数字立方和等于
该数本身。例如,153是一水仙花数。
#include <math.h>
#include <stdio.h>
int main() {
char str[4];
int n, a, b, c;
gets(str);
sscanf(str, "%d", &n);
sscanf(str, "%1d%1d%1d", &a, &b, &c);
if (pow(a, 3) + pow(b, 3) + pow(c, 3) == n) {
printf("yes");
} else {
printf("no");
}
}