描述:
阿姆斯特朗数又称水仙花数,是指一种三位数,其各个数字之立方和等于该数。
Armstrong number which is also called Daffodils number is a three-figure number,andthe sum of the number of it’s respective positions equals itself.
For example 153 = 1*1*1 + 5*5*5 + 3*3*3
输入:
本题无输入
None
输出:
升序输出
所有阿姆斯特朗数,每个数字占一行。
Output all Armstrong number in ascending order and every integer occupies aline only.
输入样例:
无
None
输出样例:
无
None
#include<iostream>
using namespace std;
int main()
{
int i,a,b,c;
for(i=100;i<1000;i++)
{
a=i/100;
b=(i%100)/10;
c=(i%100)%10;
if(i==a*a*a+b*b*b+c*c*c)
{
cout<<i<<endl;
}
}
return (0);
}