代码如下:
public class Narcissus {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a,b,c=0;
double sum = 0;
for(int i = 100;i <= 999;i++){
a = i / 100;
b = (i % 100) / 10;
c = i-(a*100+b*10);
sum = Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3);
if(sum == i){
System.out.print(i+ ” “);
}
}
}
}