# Draw circle in Matrix in c

*Circle in matrix*

*Given a MxN matrix filled with all 0s*.* how to draw a circle with given radius and center. The radius will be a positive number and the center will be index of ith row and jth column of matrix. For example we have a big matrix filled with integer numbers, like below.*

0) 1) 2) 3) 4) 5) 6) 7) 0) [ 0, 0, 0, 0, 0, 0, 0, 0 ] 1) [ 0, 0, 0, 0, 0, 0, 0, 0 ] 2) [ 0, 0, 0, 0, 0, 0, 0, 0 ] 3) [ 0, 0, 0, 0, 0, 0, 0, 0 ] 4) [ 0, 0, 0, 0, 0, 0, 0, 0 ] 5) [ 0, 0, 0, 0, 0, 0, 0, 0 ] 6) [ 0, 0, 0, 0, 0, 0, 0, 0 ]

*Let we have been given one of the cells of the matrix and the size of the circle, column = 3, row = 4 andÂ radius = 2.5. Then write a function in c such that *matrix. *doCircle(column = 3, row = 4, radius = 2.5); **so that the output matrix will be:*

0) 1) 2) 3) 4) 5) 6) 7) 0) [ 0, 0, 0, 0, 0, 0, 0, 0 ] 1) [ 0, 0, 0, 1, 1, 1, 0, 0 ] 2) [ 0, 0, 1, 1, 1, 1, 1, 0 ] 3) [ 0, 0, 1, 1, 1, 1, 1, 0 ] 4) [ 0, 0, 1, 1, 1, 1, 1, 0 ] 5) [ 0, 0, 0, 1, 1, 1, 0, 0 ] 6) [ 0, 0, 0, 0, 0, 0, 0, 0 ]

*So a circle centered at (3, 4) with the radius 2.5 has been filled with 1’s in that matrix. The circle should be as smooth as possible, and the matrices and radii could get very big.*

(The problem is taken from the http://www.javaprogrammingforums.com/algorithms-recursion/37333-find-circle-within-matrix.html, the problem is interesting).

Anybody can end code at myconcept@wikistack.com

## Leave a Reply