2 Replies Latest reply: May 11, 2007 10:37 AM by 569573 RSS

    Method for finding the smallest value of a 2d array

    807600
      so far i have
       public static void RowSumMin (int[][] table, int rows)
          { 
            int sum[] = new int[rows];
            int region=0;
            /**for (int row=0; row < table.length; row++)
               {
                  sum [row] = 0;
                  for (int col=0; col < table[row].length; col++)
                     sum [row] = sum [row] + table[row][col];      
               }
             */
            int min = my_2D_Methods.min2DSearch(table);
            
            for(int x=0; x < sum.length; x++)
            {
                if (min == sum[x])
                  region = x+1;
            }
            
            
            System.out.println("The worst annual revenue is $" + min + " in region " + region);
            
          
          }
      and
      public static int min2DSearch(int a[][])
         {
           int min = a[0][0];
             
           for (int index=0; index < a.length; index++)
           {
               for (int index2=0; index2 < a.length; index2++)
                  if(min > a[index][index2])
                   min = a[index][index2];
      
           }
              return min;
         }
      but its not working, any ideas?