#include
#include
#include
void main()
{
int xc,yc,r,gd=DETECT,gm;
void bres_cir(int,int,int);
printf("Enter the midpoints of circle and radius as xc,yc,r :\n");
scanf("%d%d%d",&xc,&yc,&r);
initgraph(&gd,&gm,"c:\\tc\\bgi");
bres_cir(xc,yc,r);
getch();
}
void bres_cir(int xc,int yc,int r)
{
int x=0,y=r,p;
void display(int,int,int,int);
p=3-2*r;
while(x<=y)
{
display(xc,yc,x,y);
if(p<0)
p+=4*x+6;
else
{
p+=4*(x-y)+10;
y--;
}
x++;
}
}
void display(int xc,int yc,int x,int y)
{
putpixel(xc+x,yc+y,14);
putpixel(xc+x,yc-y,14);
putpixel(xc-x,yc+y,14);
putpixel(xc-x,yc-y,14);
putpixel(xc+y,yc+x,14);
putpixel(xc+y,yc-x,14);
putpixel(xc-y,yc+x,14);
putpixel(xc-y,yc-x,14);
}
0 comments:
Post a Comment