![TheViperMlg23676](/avatars/39724.jpg)
TheViperMlg23676
16.01.2020 •
Computers and Technology
Write a method named matrixadd that accepts a pair of two-dimensional arrays of integers as parameters, treats the arrays as 2d matrices and adds them, returning the result. the sum of two matrices a and b is a matrix c where for every row i and column j, cij = aij + bij. you may assume that the arrays passed as parameters have the same dimensions.
Solved
Show answers
More tips
- C Computers and Internet How to easily and quickly disable Firebug in Gmail and Google Docs...
- G Goods and services How to sew a ribbon: Tips for beginners...
- F Food and Cooking How to Make Mayonnaise at Home? Secrets of Homemade Mayonnaise...
- C Computers and Internet Which Phone is Best for Internet Surfing?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
- H Horoscopes, Magic, Divination Where Did Tarot Cards Come From?...
- S Style and Beauty How to Make Your Lips Fuller? Ideas and Tips for Beautiful Lips...
- C Computers and Internet How to Learn to Type Fast?...
Answers on questions: Computers and Technology
- C Computers and Technology Emanuel studies hard for hours on end until bedtime, yet his grades could be better. What can he do to improve his academic performance? sleep less take breaks eat...
- C Computers and Technology What should a writer not include in a trip report?...
- C Computers and Technology How can the IOSP model help us to design an app that solves a problem? (IOSP IS Input/Output/Storage/Processing) PL HEL...
- C Computers and Technology Streaming media known as is stored on the provider s server, which allows you to play the media multiple times. Graphics that help a viewer know when one scene ends...
- C Computers and Technology Design a recursive algorithm called Extrema(A,p,r) that, given an array A[1...n] finds and returns both the min and max of the subarray Aſp...r] as an ordered pair:...
- C Computers and Technology Fear and superstition were swept away as scientists began to understand natural phenomena, leading to a shift in content for graphic design. In Erhard Ratdolt s , sixty...
- M Mathematics Three students attempt to define what it means for lines lll and mmm to be perpendicular. Can you match the teacher s comments to the definitions?...
- C Computers and Technology In this lesson, we looked at several related topics that involve size, including HTML, resolution speed, and file size. Imagine that you have a client that wants their...
- M Mathematics What do you think might be a rule for putting numbers in science notation in least to greatest Order ??...
- M Mathematics ERROR ANALYSIS Describe and correct the error in finding the sum. X^3- 4x^+ 3 +-3x^3+ 8x - 2 -2x^3 + 4x^+ 1 The sum of 3 and 2 is not 1. The sum of x and 3x is not...
Ответ:
The code to this question can be given as follows:
Code:
int matrixAdd(int[][] a, int[][] b) //defining method matrixAdd
{
int c[x][y]=0;//defining variable
for(int x = 0; x<a.length; x++) //loop for add rows
{
for(int y= 0; y<a[i].length; y++) //loop for add column
{
int c[x][y] = a[x][y] + b[x][y]; //add array elements
}
}
return c[x][y];//return value
}
Explanation:
In the above method definition code, a method "matrixAdd" is defined that contains two integer 2D arrays "a[][] and b[][]" in its parameter, and this function returns the sum of both array.
Inside this method, another integer 2D array "c[][]" is defined that contains nothing.To add all array elements the for loop is defined, which uses the array variable "c[][]" to add all array elements and return its value.Ответ: