java - 2D Array to Rectangles -


is there way parse 2 dimensional array rectangle object (x,y, width, height)?. need array of possible rectangles...

{0,0,0,0,0} {0,0,0,0,0} {0,1,1,0,0} {0,1,1,0,0} {0,0,0,0,0} 

this give 4 rectangles (we looking @ 0):

0,0,5,2 0,0,1,5 3,0,2,5 0,5,5,1 

i have tried this, gives area of biggest rectangle...

public static int[] findmaxrectanglearea(int[][] a, int m, int n) {     // m=rows & n=cols according question     int corx =0, cory = 0;     int[] single = new int[n];     int largex = 0, largest = 0;     (int = 0; < m; i++) {         single = new int[n]; // 1 d array used check line line &                                 // it's size n         (int k = i; k < m; k++) { // used run until                                         // contains element             int = 0;             int y = k - + 1; // used row , col of comming                                 // array             int shrt = 0, ii = 0, small = 0;             int mix = 0;             int findx = 0;             (int j = 0; j < n; j++) {                 single[j] = single[j] + a[k][j]; // postions element                                                     // added                    if (single[j] == y) { // element position equals                     shrt = (a == 0) ? j : shrt; // shortcut                     = + 1;                     if (a > findx) {                         findx = a;                         mix = shrt;                        }                 } else {                     = 0;                 }             }             = findx;              = (a == y) ? - 1 : a;             if (a * y > largex * largest) { // here checking values                                             // xy                 largex = a;                 largest = y;                 ii = i;                 small = mix;                }          }      }// end of loop     return largex * largest;  } 

this code working 1s, not point right now


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -