#include <stdio.h>
#include <math.h>
int main(int argc, const char *argv[])
{
int n = 100, a, b, c;
b = n % 100 / 10;
c = n % 10;
}
n++;
}
return 0;
}
#include <math.h>
int main(int argc, const char *argv[])
{
int n = 100, a, b, c;
while (n <= 999)
{
a = n / 100;b = n % 100 / 10;
c = n % 10;
if (pow(a,3) + pow(b, 3) + pow(c, 3) == n)
{
printf("%d\n", n);}
n++;
}
return 0;
}
本文通过C语言程序展示了如何找出100到999之间的所有水仙花数。水仙花数是指一个三位数,它的每个位上的数字的立方和等于它本身。程序采用循环和条件判断来实现这一功能。
4万+

被折叠的 条评论
为什么被折叠?



