vb.net - Algorithm problem -
i have divided circle rows , columns , each block(square) formed in circle of equal size. have x , y co-ordinates of each square/block. each block either defined or bad.
problem: need add 2 blocks on same row , determine if result or bad. if of block bad, group of 2 block called bad. if both good, group good. algorithm it? need in visual basic language. also, need more cases adding 3 blocks , determine if group of 3 block or bad. in this, if block bad, whole group bad.
update: when divided circle rows , columns i.e blocks, remove blocks not in shape of square. is, square/blocks touching circumference of circle deleted. can upload photo tomorrow now.
if adding two, 1 badblock means both on either side bad leading 3 bad on
1) set nxn array of struct {bool incircle, badblock, badgroup;} incircle true if block in circle, badblock true if block bad on , badgroup false.
3)
int length=2; length--; (int i=0; i<n;i++) for(int j=0; j<n;j++) if(array[i,j].badblock){ for(int x=-length;x<=length;x++) if(i+x>=0 , i+x<n , array[i+x,j].incircle) array[i+x,j].badgroup=true; for(int y=-length;y<=length;y++) if(j+y>=0 , j+y<n , array[i,j+y].incircle) array[i,j+y].badgroup=true; }
Comments
Post a Comment