Program Discussion :: Basics
161 / 279
Write a program to print the matrix element in clock-wise and anti clock-wise sprial, if the given value of i=0 and i=1
Ex.
| 1 2 3 4 |
| 5 6 7 8 |
| 9 10 11 12 |
| 13 14 15 16 |
OutPut:
For i=0
1 2 3 4 8 12 16 15 14 12 9 5 6 7 11 10
for i=1
1 5 9 13 14 15 16 12 8 4 3 2 6 10 11 7
Ex.
| 1 2 3 4 |
| 5 6 7 8 |
| 9 10 11 12 |
| 13 14 15 16 |
OutPut:
For i=0
1 2 3 4 8 12 16 15 14 12 9 5 6 7 11 10
for i=1
1 5 9 13 14 15 16 12 8 4 3 2 6 10 11 7
Answer: