Brock T.

asked • 03/16/22

C++ Mirrored Matrices activity

Instructions:

  1) Write a SET OF 3 OVERLOADED functions called flipMatrixHorizontal() that takes the following inputs:

  a) a 2-dimensional array with any number of rows and 3, 4, or 5 columns (this is where the overloading comes in).

  b) an array to put the flipped array values in

  c) number of rows

  d) number of columns

 The function should reverse the ROWS (rotate around the horizontal axis)of the original array and put the new values in the flipped array. 

  

 2) Write a SET OF 3 OVERLOADED functions called flipMatrixVertical() that takes the following inputs:

 a) a 2-dimensional array with any number of rows and 3, 4, or 5 columns (this is where the overloading comes in).

 b) an array to put the flipped array values in

 c) number of rows

 d) number of columns

 The function should reverse the COLUMNS (rotate around the vertical axis)of the original array and put the new values in the flipped array. 

  

 3) You should have six functions when complete.  


 Example:

 Original 3 x 3 matrix:


 0  1  2

 3  4  5

 6  7  8


 Flipped vertically:


 2  1  0

 5  4  3

 8  7  6


 Flipped horizontally:


 6  7  8

 3  4  5

 0  1  2



code given:


#include <iostream>

using namespace std;


// Fill in your 6 function definitions here. Empty shells for 2 of the 6 are provided. Start by creating the other 4 empty shells to get the test code to compile. Once the file compiles, start filling in your functions.

void flipMatrixVertical (int originalMatrix[][3], int flippedMatrix[][3], const int NUM_ROWS, const int NUM_COLUMNS){

// YOUR CODE HERE

}



void flipMatrixHorizontal (int originalMatrix[][3], int flippedMatrix[][3], const int NUM_ROWS, const int NUM_COLUMNS){

// YOUR CODE HERE

}


// YOUR CODE HERE (4 more functions)



#include "testcode.h" // for automated grading purposes; do not remove


int main() {


runTest(); //Code for automatic grading. DO NOT REMOVE


}



expected output: for 0 - 5

Expected
3x3 Vertical Passed
Original Matrix:
0 1 2
3 4 5
6 7 8
Flipped Matrix:
2 1 0
5 4 3
8 7 6


3x3 Horizontal Passed
Original Matrix:
0 1 2
3 4 5
6 7 8
Flipped Matrix:
6 7 8
3 4 5
0 1 2


2x4 Vertical Passed
Original Matrix:
0 1 2 3
4 5 6 7
Flipped Matrix:
3 2 1 0
7 6 5 4


2x4 Horizontal Passed
Original Matrix:
0 1 2 3
4 5 6 7
Flipped Matrix:
4 5 6 7
0 1 2 3

7x5 Vertical Passed
Original Matrix:
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
25 26 27 28 29
30 31 32 33 34
Flipped Matrix:
4 3 2 1 0
9 8 7 6 5
14 13 12 11 10
19 18 17 16 15
24 23 22 21 20
29 28 27 26 25
34 33 32 31 30


7x5 Horizontal Passed
Original Matrix:
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
25 26 27 28 29
30 31 32 33 34
Flipped Matrix:
30 31 32 33 34
25 26 27 28 29
20 21 22 23 24
15 16 17 18 19
10 11 12 13 14
5 6 7 8 9
0 1 2 3 4




1 Expert Answer

By:

Donald W. answered • 03/17/22

Tutor
5.0 (214)

Experienced and Patient Tutor for Math and Computer Science

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.