水仙花数

水仙花数(Narcissistic number)也被称为超完全数字不变数
(pluperfect digital invariant, PPDI)、自恋数、自幂数、
阿姆斯壮数或阿姆斯特朗数(Armstrong number),水仙花数是指一个 3 位数,
它的每个位上的数字的 3次幂之和等于它本身。


int a,b,c=0;
for (int i = 100; i <1000 ; i++) {
a=i/100;
b=i%100/10;//如153取模100等于53,53除以10取整等于5 余数为3;
c=i%10; //c=i%100%10; %100与%10为重复作用没有必要
double nums=Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3);
if(i==nums) {
System.out.println(i);
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
原文地址:https://www.cnblogs.com/ln9937/p/10950397.html