C++ Matrix Rotation by 180 degree
Submissions: 1077   Accuracy:

44.33%

  Difficulty: Easy   Marks: 2

Given a square matrix  M of N X N, turn it by 180 degrees in anticlockwise direction without using extra memory.

Input:
The first line of input contains a single integer T denoting the number of test cases. Each test case consists of two lines. The first line contains an integer N, where N is the size of the square matrix.The second line of each test case contains NxN space-separated values of the matrix M.

Output:
For each test case, the output is the rotated matrix M. 

Constraints:
1<=T<=100
1<=N<=10

Example:
Input:

1
4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Output:
16 15 14 13
12 11 10 9
8 7 6 5
4 3 2 1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Vanshika
Author: Vanshika_pec


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.