早教吧 育儿知识 作业答案 考试题库 百科 知识分享

在窗体上输出所有的“水仙花数”,并按照一行5个的格式输出。所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个“水仙花数”,因为153=1*1*1+5*5*5+3*3*

题目详情
在窗体上输出所有的“水仙花数”,并按照一行5个的格式输出。所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个“水仙花数”,因为153=1*1*1+5*5*5+3*3*3。
▼优质解答
答案和解析
我刚做了这个题目:你看看!
#include
void main()
{
int nFirst;
int nSecond;
int nThird;
int i ;
for(i=100;i<1000;i++)
{
nFirst=i/100;
nSecond=i%100/10;
nThird=i%10;
if(i == nFirst*nFirst*nFirst+nSecond*nSecond*nSecond+nThird*nThird*nThird)
printf("%d\t",i);
}
}
看了 在窗体上输出所有的“水仙花数...的网友还看了以下: