【发布时间】:2023-02-05 13:37:51
【问题描述】:
我想打印从 100000 到 1000000 的数字,每边用两个空格分隔。我想每行打印 15 列/15 个唯一数字,但每一行都打印相同的数字。如何解决这个问题
class practicex{
public static void main(String[] args) {
pract();
}
static void pract(){
for (long i=100000; i<1000000; i++){
for(long q=0; q<15; q++){
System.out.print(" " + i + " ");
}
System.out.println();
}
}
}
【问题讨论】:
-
在
for循环内部(在方法pract中)变量i的值没有改变。你知道如何使用调试器吗?如果这样做,请尝试使用它来调试您的代码。
标签: java