Question: Using C++ Sample1 Input 1 9 2 Output 9 Sample 2 Input 4 1 2 3 4 5 6 7 8 9 10 11 12

Write a program which takes as input a square matrix and prints it in spiral form with either clockwise or anticlockwise direction. An example is given below: Input matrix (anticlockwise spiral): Printed in spiral form with anticlockwise direction is: 15913141516128432610117 Remarks: 1. You can assume that the maximum size of the input matrix is 10. 2. No validity check is required for the value indicating the size of the matrix. Sample 1: Please input the size of the matrix: 1 Please input the matrix row by row: 9 Please choose the direction of spiral (1 - Clockwise, 2 - Anticlockwise): 1 The clockwise spiral form of the matrix is: 9 Sample 2: Please input the size of the matrix: 4 Please input the matrix row by row: 1234 5678 99101112 13141516 Please choose the direction of spiral (1 - Clockwise, 2 - Anticlockwise): 2 The anticlockwise spiral form of the matrix is
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
