Site hosted by Angelfire.com: Build your free website today!

 

Program 45Program 45

C++

K. Dzwonkiewicz

 

Using an apmatrix

 

Fill a 4x6 matrix with random numbers (1…50) Call the matrix num.

Create a function that will return the sum of some row + some column

but have the intersected value added just once.

Your function call will look like this perhaps...sum=SumCross(num, row–1,col-1);

Notice the call adjusts to operate on the correct subscripts…cin>>row  will get input of (1…4) and cin>>col will get (1…6)

 

Print the original 4x6 matrix

Like this…

 

12

23

  4

56

 8

21

32

11

13

43

12

14

23

 7

  7

22

31

  5

12

14

 10

 5

 3

  6

 

Sample Run…

 

Please enter a row number (not the subscript)…4

Please enter column number (not the subscript)…3

Sum is…74