#include <stdio.h>
#include <stdlib.h>
#include <math.h>
//水仙花“水仙花数”是指一个三位数
//其各位数字的立方和确好等于该数本身,如;153=1+5+3?,则153是一个“水仙花数”
//设置x,y,z分别为百位十位个位,运用pow函数;
int main(){
int x, y, z;
for (int i = 100; i <= 999; i++){
x = i / 100;
y = i / 10 % 10;
z = i % 100 % 10;
if (i==pow(x,3)+pow(y,3)+pow(z,3)){
printf("%d=%d^3+%d^3+%d^3\n",i,x,y,z);
}
}
system("pause");
return 0;
}
输出结果为: