Question: please write code in c language with comments Assume that there is an NxN (N20) matrix and filled with numbers sequentially (from 1 - N2)
please write code in c language with comments



Assume that there is an NxN (N20) matrix and filled with numbers sequentially (from 1 - N2) in every grid from the left to the right column in the top row and then from the top row to the bottom row. This is called the initial state of the matrix. After creating a matrix with the initial state, you can do two actions to this matrix. The first action is the horizontal flip which will exchange the grids with the symmetry grids in the same row. The second action is the vertical flip which will exchange the grids with the symmetry grids in the same column. The graphs below are the examples of the initial-state, horizontal-fliped, and vertical- filped matrix with N=4. Your task is to write a program that enables users to enter an integer N as matrix size and then enter another integer M represented the number of the actions that will be entered in the next line. In the second line, the user will enter M actions and each action will be 1 or 2, represent horizontal flip and vertical flip respectively. The output of the program should print the matrix with all actions performing correctly. 1 2 3 4 5 7 432 13 14 15 16 1 5 6 7 8 8 7 6 5 9 10 11 12 9 10 11 12 12 11 10 9 5 6 7 16 15 14 13 5 6 8 13 14 15 16 1 2 3 4 Initial State 1: horizontal flip 2: vertical flip There are some restrictions you need to follow: 1. You can not use external/global variables 2. You should write three required functions Function Name Description horizontal_flip Exchanging the symmetry grids in the same row. vertical_flip Exchanging the symmetry grids in the same column. swap You can choose one of these two methods to implement this function: 1. exchanging values of two variables. 2. exchanging every element of two matrices. Input Format In the first line, there are two integers N and M, which represent the size of the matrix and the number of actions respectively. The next line will have M numbers separated by space. Each number will be either 1 (horizontal flip) or 2 (vertical flip) representing different actions that you need to apply on the matrix. Please see the input example below. Output Format The final content of the matrix after applying all given actions. The output should contain N lines and each line has N numbers separated by space. Please see the output example below. Technical specifications ISN
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
