Page 346 - Cs_withBlue_J_C11_Flipbook
P. 346

43                  maxCol--;
                44                  maxRow--;

                45              }
                46              for ( i = 0; i < s; i++)

                47              {
                48                  for ( j = 0; j < s; j++)

                49                  {
                50                      System.out.print(sparr[i][j]+ "\t");
                51                  }

                52                  System.out.println();

                53              }
                54          }
                55

                56           public static void main()
                57          {

                58              Scanner sc = new Scanner(System.in);
                59              int n;

                60              System.out.println("Enter the size:");
                61              n = sc.nextInt();

                62              spiral ob= new spiral(n);
                63              ob.display();

                64          }
                65      }


              The output of the program is as follows:

              Enter the size:
              5
              1      2       3      4      5
              16     17      18     19     6

              15     24      25     20     7
              14     23      22     21     8
              13     12      11     10     9












                344344  Touchpad Computer Science-XI
   341   342   343   344   345   346   347   348   349   350   351