/*
7--打印所有的“水仙花数”。所谓的“水仙花数”,是指一个三位数,
其各位数字的立方和等于该数本身的。
*/
#include<stdio.h>
#include<math.h>
void main()
{
int x,i,j,k;
for( x=100;x<1000;x++)
{
i = x/100;
j = x %100/10;
k = x % 100 %10;
if(x == pow(i,3)+pow(j,3)+pow(k,3))
printf("水仙数有 :%d \n",x);
}
}
7--打印所有的“水仙花数”。所谓的“水仙花数”,是指一个三位数, 其各位数字的立方和等于该数本身的。
最新推荐文章于 2021-12-08 13:09:33 发布