#include
#include
#include
#include
#include
void main()
{
int gd=DETECT, gm;
int x,y,p,r;
char ch;
initgraph (&gd,&gm,"c:\\tc\\bgi");
x=getmaxx();
y=getmaxy();
setlinestyle(0,0,1);
setcolor(WHITE);
line (x/2,0,x/2,y);
line(0,y/2,x,y/2);
putpixel(x/2,y/2, BLACK);
outtextxy(x/2+2,y/2+2,"0");
putpixel(x/2+40,y/2, BLACK); //lits the pixel
outtextxy(x/2+40,y/2+2,"40");
putpixel(x/2+80,y/2, BLACK);
outtextxy(x/2+80,y/2+2,"80");
putpixel(x/2+120,y/2, BLACK);
outtextxy(x/2+120,y/2+2,"120");
putpixel(x/2+160,y/2, BLACK);
outtextxy(x/2+160,y/2+2,"160");
putpixel(x/2+200,y/2, BLACK);
outtextxy(x/2+200,y/2+2,"200");
putpixel(x/2+240,y/2, BLACK);
outtextxy(x/2+240,y/2+2,"240");
putpixel(x/2-40,y/2, BLACK);
outtextxy(x/2-40,y/2+2,"-40");
putpixel(x/2-80,y/2, BLACK);
outtextxy(x/2-80,y/2+2,"-80");
putpixel(x/2-120,y/2, BLACK);
outtextxy(x/2-120,y/2+2,"-120");
putpixel(x/2-160,y/2, BLACK);
outtextxy(x/2-160,y/2+2,"-160");
putpixel(x/2-200,y/2, BLACK);
outtextxy(x/2-200,y/2+2,"-200");
putpixel(x/2-240,y/2, BLACK);
outtextxy(x/2-240,y/2+2,"-240");
putpixel(x/2,y/2+40, BLACK);
outtextxy(x/2,y/2+40,"-40");
putpixel(x/2,y/2+80, BLACK);
outtextxy(x/2,y/2+80,"-80");
putpixel(x/2,y/2+120, BLACK);
outtextxy(x/2,y/2+120,"-120");
putpixel(x/2,y/2+160, BLACK);
outtextxy(x/2,y/2+160,"-160");
putpixel(x/2,y/2+200, BLACK);
outtextxy(x/2,y/2+200,"-200");
putpixel(x/2,y/2+240, BLACK);
outtextxy(x/2,y/2+240,"-240");
putpixel(x/2,y/2-40, BLACK);
outtextxy(x/2+2,y/2-40,"40");
putpixel(x/2,y/2-80, BLACK);
outtextxy(x/2+2,y/2-80,"80");
putpixel(x/2,y/2-120, BLACK);
outtextxy(x/2+2,y/2-120,"120");
putpixel(x/2,y/2-160, BLACK);
outtextxy(x/2+2,y/2-160,"160");
putpixel(x/2,y/2-200, BLACK);
outtextxy(x/2+2,y/2-200,"200");
putpixel(x/2,y/2-240, BLACK);
outtextxy(x/2+2,y/2-240,"240");
printf("Enter the radius ");
scanf("%d",&r);
x=0;y=r;
plot(x,y);
p=1-r;
while (x
if(p<0)
{
x=x+1;
p=p+2*x+1;
}
else
{
x=x+1;
y=y-1;
p=p+2*(x-y)+1;
}
plot(x,y);
}
getch();
closegraph();
}
int plot(int x,int y)
{
int xc,yc;
xc=getmaxx()/2;
yc=getmaxy()/2;
putpixel(xc+x,yc+y,WHITE);
putpixel(xc-x,yc+y,WHITE);
putpixel(xc+x,yc-y,WHITE);
putpixel(xc-x,yc-y,WHITE);
putpixel(xc+y,yc+x,WHITE);
putpixel(xc-y,yc+x,WHITE);
putpixel(xc+y,yc-x,WHITE);
putpixel(xc-y,yc-x,WHITE);
return(0);
}
No comments:
Post a Comment