您的位置:首页 > 其它

7--打印所有的“水仙花数”。所谓的“水仙花数”,是指一个三位数, 其各位数字的立方和等于该数本身的。

2017-03-16 15:01 561 查看
/*
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);

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐