// Draw a circle with center (x,y) and radius r circle(int x, int y, int r) { int a = 0; int b = r; while(a <= b) { // Draw the current location in all 4 quadrants plot(x+a, y+b); plot(x-a, y+b); plot(x+a, y-b); plot(x-a, y-b); plot(x+b, y+a); plot(x-b, y+a); plot(x+b, y-a); plot(x-b, y-a);
// Look at two possible next points and pick the better int delta1 = r*r - (a+1)*(a+1) - b*b; int delta2 = r*r - a*a - (b-1)*(b-1); if (delta1*delta1 < delta2*delta2) ++a; else --b; } } On Aug 5, 8:38 am, rShetty <rajeevr...@gmail.com> wrote: > Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without > making use of any floating point > computations at all. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.