How to sum a row in a matrix

后端 未结 6 1953
情话喂你
情话喂你 2021-01-23 05:54

Write the method:

public int sumRow(int[][] matrix, int row)

that sums row row in the 2D array called matrix.

Given:

6条回答
  •  無奈伤痛
    2021-01-23 06:45

    In the internal loop, modify the condition to:

    for(int j = 0; j < matrix[i].length; j++)
    

    and then switch i and j in the sum

提交回复
热议问题