-1
How to sum the values of each row of a matrix and store the sum in one array? Example:
3 3 3
2 3 4
2 2 2
Results in:
9
9
6
-1
How to sum the values of each row of a matrix and store the sum in one array? Example:
3 3 3
2 3 4
2 2 2
Results in:
9
9
6
4
I think you should start thinking about wearing a bow tie for
Example to help...
int[][] num = new int[3][3];
for (int i = 0; i < num.length; i++) {
int sum = 0;
for (int j = 0; j < num[i].length; j++) {
sum += num[j][i];
}
System.out.println(sum);
}
I have something like this for (i=0; i<eq;i++)' masG[i]=masG[i]+puntos[i][j]; for(j=0; j<eq;j++){ if(i==j){pointers[i][j]=0;} Else{ soma+=puntos[i][j]; masG[i]=soma; } }
sorry so actually it is (i=0; i<eq;i++)' for(j=0; j<eq;j++){ if(i==j){puntos[i][j]=0;} Else{ soma+=puntos[i][j]; masG[i]=soma; } }
Marcio, it’s hard to analyze the code you sent. I think it’s nice that you analyze the code better and try to "debug" to understand what the loop is doing.
Browser other questions tagged java matrix
You are not signed in. Login or sign up in order to post.
and store the sum in an array.
– Marcio.Rezende