Question: Requirements: Obtain a file name from the user, which will contain data pertaining to a 2D array Create a file for each of the following:
Requirements:
Obtain a file name from the user, which will contain data pertaining to a 2D array
Create a file for each of the following:
averages.txt : contains the overall average of the entire array, then the average of each row
reverse.txt : contains the original values but each row is reversed
flipped.txt : contains the original values but is flipped top to bottom (first row is now the last row etc.)
If the dimensions of array are symmetric (NxN), create a diagonal.txt: contains the array mirrored on the diagonal
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Example files
The input file will be formatted in the following way:
Sample file called "input.txt"
4 4 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0
Output to averages.txt
Total average: 8.5 Row 1 average: 2.5 Row 2 average: 6.5 Row 3 average: 10.5 Row 4 average: 14.5
Output to reverse.txt
4.0 3.0 2.0 1.0 8.0 7.0 6.0 5.0 12.0 11.0 10.0 9.0 16.0 15.0 14.0 13.0
Output to flipped.txt
13.0 14.0 15.0 16.0 9.0 10.0 11.0 12.0 5.0 6.0 7.0 8.0 1.0 2.0 3.0 4.0
Since it's symmetric we also get diagonal.txt
1.0 5.0 9.0 13.0 2.0 6.0 10.0 14.0 3.0 7.0 11.0 15.0 4.0 8.0 12.0 16.0
----------------------------------------------
I need it in C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
