# Include <math. h>
# Include <graphics. h>/* pre-defined library functions */
Void circlePoint (int x, int y)/* circle program by octal Method */
{
Circle (320 + x * 20,240 + y *, 3 );
Circle (320 + y * 20,240 + x *, 3 );
Circle (320-y * 20,240 + x * 20, 3 );
Circle (320-x * 20,240 + y * 20, 3 );
Circle (320-x * 20,240 + y * 20, 3 );
Circle (320-x * 20,240-y * 20, 3 );
Circle (320-y * 20,240-x * 20, 3 );
Circle (320 + y * 20,240-x *, 3 );
Circle (320 + x * 20,240-y *, 3 );
}
Void MidBresenhamcircle (int r)/* circle program of the midpoint Bresenham algorithm */
{
Int x, y, d;
X = 0; y = r; d = 1-r;/* calculate the initial value */
While (x <y)
{CirclePoint (x, y);/* draw points (x, y) and the other seven symmetry points in the octal circle */
If (d <0) d + = 2 * x + 3;/* determines whether to go or not in the non-maximum displacement direction based on the judgment of the error item d */
Else
{D + = 2 * (x-y) + 5;
Y --;
}
X ++;
Delay (900000 );
}/* While */
}
Main ()
{
Int I, j, r, graphmode, graphdriver;
Detectgraph (& graphdriver, & graphmode );
Initgraph (& graphdriver, & graphmode ,"");
Printf ("program whose circle is drawn by the mid-point Bresenhamcircle algorithm n");/* message */
Printf ("note | r | <= 11 ");
Printf ("n input radius value r :");
Scanf ("% d", & r );
Printf ("press any key to display the image ...");
Getch ();
Cleardevice ();
Setbkcolor (BLACK );
For (I = 20; I <= 620; I + = 20)/* use the double loop point function to draw the ordinate coordinates in the table */
For (j = 20; j <= 460; j ++)
Putpixel (I, j, 2 );
For (j = 20; j <= 460; j + = 20)