/*Spirally traversing a matrix Traversing an array is an elementary operation on an array, in which each element will be processed for some operation. Printing elements is one example operation. So, complete the below function, which given a two dimensional array, print the array in spiral form rotating clockwise. Input Format Each test-case will begin with two number m and n where m = no. of rows and n = no. of columns. m rows will follow with n integers in each row separated by a space. Constraint : 1<=m<=50 and 1<=n<=50. Output Format For each test case, print the elements of 2-d array in spiral form starting from index (0,0) or upper-left corner in clockwise direction.*/ import java.util.*; public class SpiralMatrix { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int r=sc.nextInt(); int c=sc.nextInt(); int arr[][]=new int[r][c]; for(int i=0;i=c1;i--) { System.out.println(arr[r-1][i]); } r--; } if(c1=r1;i--) { System.out.println(arr[i][c1]); } c1++; } } } }