Java List Sum sumAllColumnsOfMatrix(List> matrix)

Here you can find the source of sumAllColumnsOfMatrix(List> matrix)

Description

sum All Columns Of Matrix

License

Open Source License

Declaration

public static List<Integer> sumAllColumnsOfMatrix(List<List<Integer>> matrix) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<Integer> sumAllColumnsOfMatrix(List<List<Integer>> matrix) {
        List<Integer> result = new ArrayList<Integer>();
        for (int i = 0; i < matrix.size(); i++) {
            Integer columnTotal = 0;
            for (int j = 0; j < matrix.size(); j++) // loop over all columns of matrix
            {/*www .j a v  a  2  s . c  o m*/
                List<Integer> row = matrix.get(j);
                for (int k = 0; k < row.size(); k++) // loop over all rows of matrix
                {
                    if (k == i) {
                        columnTotal = (columnTotal + row.get(k)) % 26;
                        break;
                    }
                }
            }
            result.add(columnTotal);
        }
        return result;
    }
}

Related

  1. sum(List numbers)
  2. sum(List numbers)
  3. sum(List listOfNumbers)
  4. sum_ints(List list)
  5. sumAll(List list)
  6. sumCreditList(List list)
  7. sumDifferences(List a, List b)
  8. sumDouble(List list)
  9. sumInteger(List list)