好的,我正在为我的编程课程制作一个程序,我正在尝试获取它,所以当我输入列和行时,它会得到一个显示乘法表的输出。下面是一个可视化的示例: printTable(4,6) 的示例运行输出:
现在,这是我的代码:
import java.util.Scanner;
public class Pictures {
public static int row;
public static int column;
public static Scanner input = new Scanner(System.in);
public static void main(String[] args){
int x = 1;
int y = 1;
System.out.println("Input Row: ");
row = input.nextInt();
System.out.println("Input Column: ");
column = input.nextInt();
for(x = 1; x < row; x++){
System.out.print(x * y + " ");
for(y = 1 ; y < column; y++){
System.out.print(y * x + " ");
}
System.out.println();
}
}
}
现在,当我输入第 5 行和第 5 列时,我的输出如下所示:
1 1 2 3 4
10 2 4 6 8
15 3 6 9 12
20 4 8 12 16
我知道我没有看到一些相当简单的东西,但我就是不明白为什么会这样。如果有人可以提供建议,那将有很大帮助。
谢谢,萨利