Page 531 - Cs_withBlue_J_C11_Flipbook
P. 531
41 /* Printing the spiral matrix */
42 System.out.println("The Spiral Matrix is:");
43 for(int i=0;i<n;i++)
44 {
45 for(int j=0;j<n;j++)
46 {
47 System.out.print(A[i][j]+ "\t");
48 }
49 System.out.println();
50 }
51 }//end of display
52 public static void main(String args[])
53 {
54 Spiral_Matrix ob=new Spiral_Matrix();
55 ob.spiralprint();
56 }
57 }
The output of the preceding program is as follows:
Enter the number of elements :
3
The Spiral Matrix is:
1 2 3
8 9 4
7 6 5
Variable Description
NAME TYPE DESCRIPTION
A[][] int To store the array
i int Loop variable
j int Loop variable
r1 int To store the number of rows of the 1st array
r2 int To store the number of rows of the 2nd array
c1 int To store the number of columns of the 1st array
c2 int To store the number of columns of the 2nd array
529
Internal Assessment 529

