There is a 100x100 matrix and an array of one hundred elements. It is necessary to sum up the array and each row of the matrix and write it into a separate array. Is this possible ???

public class Distance { public static int[] distance(int[] etalonMatrix, int[][] convertToMatrix){ int[] etalon = etalonMatrix; int [][] matrix = convertToMatrix; int [] distance = new int[80]; } } 

I tried to draw it all, but I draw badly ( enter image description here

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants Artem Konovalov , rjhdby , aleksandr barakin , cheops , fori1ton 19 Oct '16 at 14:35 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • four
    yes, perhaps, add the code of the matrix and indicate that you can not. - MrFylypenko
  • @Dasha Novikova Maybe you were mistaken with the description of your task? A more natural description would be as follows. There is a matrix and there is an array. You need the sum of the elements of the matrix in rows to add to the array. Or do you mean that the elements of each row of the matrix are summed with the elements of the array? - Vlad from Moscow
  • five
    Very similar to the educational task that the author does not want to solve himself. - Vasily Koshelev
  • @MrFylypenko rules - Dasha Novikova
  • @VladfromMoscow rules - Dasha Novikova

1 answer 1

 for(int x = 0; x < 100; x++) { for(int y = 0; y < 100; y++) { distance[x] += etalon[x] + matrix[x][y]; } } return distance; 
  • Understood, all right, only after 1 cycle you need to reset the distace - Dasha Novikova