不知道如何增加二维数组



所以,基本上,我想对我的代码做的是让用户可以输入一个值,然后程序会将任何值添加到数组中的所有值

//我的代码

{
    //creates array called table
    int[][] table = new int [10][10];
    //load the table with values
    for (int row=0; row < table.length; row++)
        for (int col=0; col < table[row].length; col++)
            table[row][col] = row * 10 + col;
    //Print the table
    for (int row=0; row < table.length; row++)
    {
        for (int col=0; col < table[row].length; col++)
            System.out.print (table[row][col] + "t");
        System.out.println();
int incr;
Scanner scan = new Scanner(System.in);
System.out.println("");
System.out.println("What do you want to increment by?");
incr = scan.nextInt();

for (int row=0; row < table.length; row++)
    {
        for (int col=0; col < table[row].length; col++)
            System.out.print (table[row][col] + "t");
       System.out.println();

    }
}

到目前为止,这是我的代码,我不知道该从哪里开始。如果有人能帮我弄清楚,那就太好了。

在循环中添加这行代码:table[row][col]+=incr;

最新更新