Sum of square matrices P26374


Statement
 

pdf   zip   main.cc   main.java   main.py

html

Write a function that, given two square matrices a and b, computes their sum.

Interface

C++
typedef vector< vector<int> > Matrix;
 
Matrix sum(const Matrix& a, const Matrix& b);
Java
public static int[][] sum(int[][] a, int[][] b);
Python
sum(a, b) # returns list
 
sum(a: list[list[int]], b: list[list[int]]) -> list[list[int]]

Precondition

a and b are square matrices n× n with n ≥ 0.

Information
Author
Jordi Petit
Language
English
Translator
Carlos Molina
Original language
Catalan
Other languages
Catalan
Official solutions
C++ Java Python
User solutions
C++ Java Python