Given a 2-D array of order NxN, swap the values of the triangle above the diagonal with the values of the triangle below it like a mirror image swap. Print the 2-D array obtained in matrix layout. Let the elements of the 2-D array be denoted by A[ i ][ j ], where i, j vary from 0 to N-1.

**Input:**

First line of input is an integer T, denoting the number of test cases. For each test case, first line of input is an integer N, denoting order of square matrix. Next line consists of NxN elements of the matrix, separated by a space.

**Output:**

For each test case, output the resultant matrix in the next line.

**Constraints:**

1<= T <= 40

1<= N < 50

0<= A[ i ][ j ] < 50

**Example:
Input:**

1

3

1 2 4 5 9 0 3 1 7

1 5 3 2 9 1 4 0 7

**Explanation:**

Elements above the diagonal are swapped with the elements below the diagonal like mirror image swap, treating diagonal as the mirror and keeping it's elements unchanged.

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.

codersanjeev | 66 |

snow_den_ | 60 |

BoggavarapuRamSaranSaiSrinivasGupta | 60 |

rajupraaa1234 | 53 |

SUZAKU | 49 |

mr_kksparrow | 433 |

manvirag982 | 258 |

snow_den_ | 232 |

arpit_anshuman | 228 |

SoumyaKaushik | 205 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.