From the course: Level Up: C
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Rotating a matrix - C Tutorial
From the course: Level Up: C
Rotating a matrix
(stars dinging) (bright music) - [Instructor] Your C challenge is to rotate a grid 90 degrees clockwise. A matrix is like a grid, a two-dimensional array of rows and columns. Assume the grid is a five-by-five array. Have the grid initially filled with random characters. Rotate the grid 90 degrees clockwise. Then output the rotated grid. Pause the video now to... Wait a second. This challenge is way too easy. Let me start over. (tape rewinding) (stars dinging) (bright music) A matrix doesn't always have to be the same number of rows and columns. Some are uneven. Yet they may still need to be rotated. For this challenge, rotate three matrices, one three-by-eight, one five-by-five, and the last, six-by-four. Initialize each matrix with random characters. Output the original. Rotate it. Then output the rotated matrix. Here is sample output for my solution. These characters are random, but you can see…
Contents
-
-
-
Generating ordinal values2m 34s
-
(Locked)
Centering text2m 22s
-
(Locked)
Making change2m 17s
-
(Locked)
Simulating the hailstone sequence2m 36s
-
(Locked)
Performing a perfect shuffle2m 23s
-
(Locked)
Chopping up a string2m 49s
-
(Locked)
Determining a leap year2m 35s
-
(Locked)
Shuffling a playlist2m 32s
-
(Locked)
Letting the king wander2m 20s
-
(Locked)
Rotating a matrix2m 31s
-
(Locked)
Calculating next Monday's date2m 32s
-
(Locked)
Adding commas to numeric output2m 25s
-
(Locked)
Scoring a frame in bowling2m 20s
-
(Locked)
Calculating the golden ratio2m 50s
-
(Locked)
Wrapping text2m 9s
-