这个上课的时候有讲的吧?
class Test1_While {
public static void main(String[] args) {
int count = 0; //定义变量记录个数
int i = 100;
while (i <= 999) {
int ge = i % 10;
int shi = i / 10 % 10;
int bai = i / 100;
if (i == ge * ge * ge + shi * shi * shi + bai * bai * bai) {
count ++;
}
i++;
}
System.out.println("count =" + count);
}
}
} |