English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Looking for a C program that returns the biggest nonoccupied sub-square in a square(nXn). e.g.:
0 0 0 0 0 0
0 1 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 1 0 0 0
0 0 0 0 0 1
This input should result in the output:
position: (1,2) /*second row third column*/
and size = 3 (Largest nonoccupied subsquare is of size 3X3)

2007-02-23 16:37:42 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

what about a brute force function ?

scan the bord if you encounter an 0, call the function explore(upperleftcorner,size) wich returns true if it is a square of size size otherwise false. call this function for each empty cell with inrceasing csize until it returns false.

it is a dumb solution but it will work , if you think harder you might come up with something more cleaner

2007-02-23 19:48:38 · answer #1 · answered by gjmb1960 7 · 0 0

fedest.com, questions and answers