Page 322 - Computer science 868 Class 12
P. 322

5           int mat[][];

                 6           void input()

                 7           {
                 8               Scanner sc = new Scanner(System.in);
                 9               int i,j,zeros = 0;

                10               System.out.print("Enter the number of rows : ");
                11               r = sc.nextInt();

                12               System.out.print("Enter the number of columns : ");
                13               c = sc.nextInt();

                14               mat = new int[r][c];
                15               System.out.println("Enter the elements of the matrix: ");

                16               for(i=0; i<r; i++)
                17               {

                18                   for(j=0; j<c; j++)
                19                   {

                20                        mat[i][j] = sc.nextInt();
                21                   }

                22               }
                23           }

                24
                25           void check_sparse()

                26           {
                27               int i,j,zeros=0;

                28               for(i=0; i<r; i++)
                29               {
                30                   for( j=0; j<c; j++)

                31                   {

                32                       if(mat[i][j] == 0)
                33                       {
                34                           zeros++;

                35                       }
                36                   }

                37               }
                38





                320320  Touchpad Computer Science-XII
   317   318   319   320   321   322   323   324   325   326   327