水仙花数
水仙花数(Narcissistic number)也被称为超完全数字不变数(pluperfect digital invariant, PPDI)、自恋数、自幂数、阿姆斯壮数或阿姆斯特朗数(Armstrong number),水仙花数是指一个 n 位数(n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身(例如:1^3 + 5^3+ 3^3 = 153)。
#include<iostream>
using namespace std;
int main()
{
int i,a,b,c,j;
int m,n;
while(cin>>m>>n)
{
j=0;
if(m>=100&&m<=n&&n<=999)
{
for(i=m;i<=n;i++)
{
a=i/100;
b=i/10-a*10;
c=i%10;
if(i==a*a*a+b*b*b+c*c*c)
{
if(j==0)
cout<<i;
if(j>0)
cout<<" "<<i;
j++;
}
}
if(j==0)
cout<<"no";
cout<<endl;
}
}
return 0;
}