水仙花数(题)
1 public class hello 2 { 3 public static void main(String[] args) 4 { 5 for(int i=100;i<=999;i++) 6 { 7 int a=i/100;//提取出百位 8 int b=i/10%10;//提取出十位 9 int c=i%10;//提取出个位 10 11 if(a*a*a+b*b*b+c*c*c==i) 12 { 13 System.out.println(i);//判断成立输出这个三位数 14 } 15 } 16 } 17 } 18 //题目:求100-999之中,其各位数字立方和等于该数本身,其中都有哪些数成立。例:153=1的三次方+5的三次方+3的三次方

浙公网安备 33010602011771号