- int a,b,c,sum ;
- StringBuilder sb = new StringBuilder();
- for (int i =100;i<1000;i++){
- sb.append(i);
- a = sb.charAt(0)-48;
- b = sb.charAt(1)-48;
- c = sb.charAt(2)-48;
- sum = a*a*a+b*b*b+c*c*c;
- if(sum == i){
- System.out.println(i);
- }
- sb.delete(0,sb.length());
- }
复制代码 |