XIAOPY

水仙花数: 各位数字的立方和等于这个三位数本身

代码示例:

package judgment;
/**
* 求三位数的水仙花数
* 水仙花数:各位数的立方和等于这个数本身
*/
public class Judgment {
public static void main(String[] args) {
for (int i = 100; i <1000 ; i++) {//以下判断条件,分别为取个位,十位,百位
if (i==(i%10)*(i%10)*(i%10)+(i%100/10)*(i%100/10)*(i%100/10)+(i/100)*(i/100)*(i/100)){
System.out.println(i);
}
}
}
}

输出示例图:


分类:

技术点:

相关文章:

  • 2021-09-11
  • 2021-09-11
  • 2021-09-11
  • 2021-09-11
  • 2021-07-13
  • 2018-11-24
  • 2021-09-11
  • 2021-09-11
猜你喜欢
  • 2021-09-11
  • 2021-09-11
  • 2021-09-11
  • 2021-09-11
  • 2021-07-19
  • 2021-09-11
  • 2021-09-11
相关资源
相似解决方案