Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Write a C++ program that reads the name of a file and then reads the data of a 2-dimensional array from the file. In

Write a C++ program that reads the name of a file and then reads the data of a 2-dimensional array from the anther Sample input/output: Enter a file name: 2D3.txt The Matrix Dimensions are 10X10 The Matrix elements

Write a C++ program that reads the name of a file and then reads the data of a 2-dimensional array from the file. In the first line, assume that the file line has 2 numbers separated by a space specifying the dimension of the 2-dimensional array in the file, and then the file starts listing the elements of the matrix one row per line. The program will then rotate the matrix elements around its center 90 degrees and store the resulting matrix with the new size information in the same input file. For example, if the matrix contains 1234 5678 The resulting matrix after the rotation will be: 48 37 26 15 8765 Sample input/output: Enter a file name: 2D1.txt The Matrix Dimensions are 2X5 The Matrix elements are: 1 2 3 4 5 6 7 8 9 10 The Matrix Dimensions after rotation are 5X2 The Matrix elements are: 5 10 49 38 27 16 anther Sample input/output: Enter a file name: 2D3.txt The Matrix Dimensions are 10X10 The Matrix elements are: 2 22 1 29 3 8 19 22 6 42 12 50 28 5 42 1 22 20 11 47 12 22 6 12 42 33 50 20 12 9 18 48 8 28 11 42 18 8 2 6 3 19 5 47 33 48 2 47 47 5 10 1 29 26 17 46 44 17 13 47 9 35 11 34 32 15 22 46 46 2 35 7 11 47 26 44 48 17 17 9 34 15 35 8 15 12 46 13 35 32 22 7 15 3 The Matrix Dimensions after rotation are 10X10 The Matrix elements are: 10 12 46 13 35 32 22 7 15 3 34 15 35 8 15 46 2 35 7 6 46 15 22 2 11 34 32 48 47 9 35 33 44 17 13 5 48 17 17 9 47 47 26 44 47 11 19 5 8 3 29 47 5 10 47 48 12 47 33 48 2 28 18 8 11 42 50 20 12 9 18 12 22 6 12 42 1 42 1 20 11 22 6 42 12 50 28 8 222 2 22 1 29 3 26 17 46 47 5 47 48 12 19 47 5 10

Step by Step Solution

5.00 Ratings (1 Votes)

There are 3 Steps involved in it

Step: 1

include include include void rotateMatrixstdvector matrix stdvector rotatedMatrixmatrix0size stdvect... blur-text-image

Get Instant Access with AI-Powered 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 C# How to Program

Authors: Paul J. Deitel, Harvey Deitel

6th edition

978-0134601540

More Books

Students also viewed these Programming questions

Question

Incorrect Your answer is incorrect. P(-1.12

Answered: 1 week ago