Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve in c + + Question 2 Given an n m matrix, a , where each a ( i , j ) is the value

solve in c++
Question 2
Given an nm matrix, a, where each a(i,j) is the value of the cell at the intersection of row i and column j, create another nm matrix, b, using the following algorithm to set the values of each b(x,y) with zerobased indexing:
s=
for
for
s=s+a(i,j)
}
}
b(x,y)=s
Note that the algorithm sets just one b(x,y) per execution and that 0y
If matrix ais:
123
456
The following operations are performed:
Element
Values
b(,0)
1
b(0,1)
1+2
b(0,2)
a(0,0)+a(0,1)+a(0,2)
a(0,0)
b(x,y)
1
6
b(1,0)
a(0,0)+a(1,0)
1+4
5
b(1,1)
1+2+4+5
b(1,2)
1
a(0,0)+a(0,1)
3
2
3
a(0,0)+a(0,1)+a(0,2)1+2+3+4+5+6,
1+2+3+4+5+6,21
+a(1,0)+a(1,1)+a(1,2)
a(0,0)+a(0,1)
12
+a(1,0)+a(1;1)
1+2+3
136
5,12,21
Function Description
ALL. Complete the function findMatrix in the editor below.
findMatrix has the following parameter(s): int a[n][m]: a2-dimensional array of
1 integers
Returns:
2 int [n][m] : the calculated 2-dimensional array of integers denoting b
3
Constraints
1n,m103
0a(i,j)103, where 2n=22a[]m=20j.
Input Format for Custom Testing
Sample Case 0
Sample Input
STDIN Function
2 number of rows ina[]
n=2
2 number of columns in
a[]m=2
120i and 0j.
Input Format for Custom Testing
Sample Case 0
Sample Input
STDIN Function
2 number of rows ina[]
n=2
2 number of columns in
a[]m=2
12
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

ISBN: 0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

=+ (b) Show that the reverse implication holds if 22 is countable.

Answered: 1 week ago