50,613
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
import java.util.Scanner;
public class Main2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i, j, n, m, a, b, c;
while (sc.hasNextInt()) {
m = sc.nextInt();
n = sc.nextInt();
for (i = m, j = 0; i <= n; i++) {
a = i / 100;
b = i / 10 % 10;
c = i % 10;
if (a * a * a + b * b * b + c * c * c == i) {
if (j > 0) {
System.out.print(" " + i);
} else {
System.out.print(i);
}
j++;
}
}
if (j == 0) {
System.out.print("no");
}
System.out.println();
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int start, end;
int[] results = new int[10];
while (sc.hasNext()) {
start = sc.nextInt();
end = sc.nextInt();
int counter = 0;
for (int i = start; i < end + 1; i++) {
if(isSpecial(i)) {
// 将结果先放在数组中,方便控制输出和换行
results[counter] = i;
counter++;
}
}
if(results[0] == 0) {
System.out.println("no");
} else {
for (int i = 0; i < counter; i++) {
if(i == 0) {
System.out.print(results[i]);
} else {
System.out.print(" "+results[i]);
}
/*if(i == counter-1) {
// 最后一个结果换行
System.out.println(results[i]);
} else {
System.out.print(results[i]+" ");
}*/
}
System.out.println();
}
}
}
private static boolean isSpecial(int n) {
int a, b, c;
// 个位
a = n%10;
// 十位
b = (n/10)%10;
// 百位
c = (n/100);
return (a*a*a + b*b*b + c*c*c) == n;
}
}
100
999
153 370 371 407
100
500
153 370 371 407
[/code]