PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
int x,y,p;
void plotcircle(int xc,int
yc,int color)
{
putpixel(xc+x,yc+y,color);
putpixel(xc+y,yc+x,color);
putpixel(xc+x,yc-y,color);
putpixel(xc+y,yc-x,color);
putpixel(xc-x,yc-y,color);
putpixel(xc-y,yc-x,color);
putpixel(xc-x,yc+y,color);
putpixel(xc-y,yc+x,color);
}
void bicircle(int xcen,int
ycen,int rad,int color)
{
x=0;
y=rad;
plotcircle(xcen,ycen,color);
p=1-rad;
while(x<y)
{
if(p<0)
++x;
else
{
++x;
--y;
}
if(p<0)
p+=2*x+1;
else
{
p+=2*(x-y)+1;
plotcircle(xcen,ycen,color);
}
}
}
void main()
{
int
gd=DETECT,gm,xc,yc,radius,color;
initgraph(&gd,&gm,"");
printf("\nEnter x pos,y
pos and radius");
scanf
("%d%d%d",&xc,&yc,&radius);
x=0;
y=radius;
plotcircle(xc,yc,color);
p=1-radius;
while(x<y)
{
if(p<0)
++x;
else
{
++x;
--y;
}
if(p<0)
p+=2*x+1;
else
{
p+=2*(x-y)+1;
plotcircle(xc,yc,color);
}
}
getch();
bicircle(xc,yc,radius,color);
}
0 comments:
Post a Comment