#include<stdio.h>
#include<graphics.h>
void MidPointCircle(int r,int color);
void CirclePoints(int x,int y,int color);
void main()
{
int gdriver=DETECT, gmode;
initgraph(&gdriver, &gmode," ");
setbkcolor(BLACK);
MidPointCircle(100,BLUE); /*下次画圆半径大点,你给的半径真夸张*/
getch();
closegraph();
}
void MidPointCircle(int r,int color)
{
int x,y;
float d;
x=0;
y=r;
d=1.25-r;
CirclePoints(x,y,color);
while(x<y)
{
if(d<0)
d+=2*x+3;
else
{
d+=2*(x-y)+5;
y--;
}
x++;
CirclePoints(x,y,color); /*重点是这里*/
}
}
void CirclePoints(int x,int y,int color) /*圆心为(320,240)*/
{
putpixel(320+x,240+y,color);
putpixel(320+y,240+x,color);
putpixel(320-x,240+y,color);
putpixel(320+y,240-x,color);
putpixel(320+x,240-y,color);
putpixel(320-y,240+x,color);
putpixel(320-x,240-y,color);
putpixel(320-y,240-x,color);
}