#include<conio.h>
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,xc,yc,r,x,y,p;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
printf("Enter xc and yc:");
scanf("%d%d",&xc,&yc);
printf("Enter radius:");
scanf("%d",&r);
x=0;
y=r;
p=3-2*r;
do
{
delay(25);
putpixel(xc+x,yc+y,1);
putpixel(xc+y,yc+x,2);
putpixel(xc-x,yc+y,1);
putpixel(xc+y,yc-x,2);
putpixel(xc-y,yc-x,1);
putpixel(xc-x,yc-y,2);
putpixel(xc+x,yc-y,1);
putpixel(xc-y,yc+x,2);
if(p<0) {
p=p+4*x+6;
}
else
{
p=p+4*(x-y)+10;
y=y-1;
}
x=x+1;
}
while(x<y)
putpixel(xc+x,yc+y,2);
getch();
closegraph();
}
#include<graphics.h>
#include<stdio.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm,xc,yc,r,x,y,p;
initgraph(&gd,&gm,"c:\\tc\\bgi");
cleardevice();
printf("Enter xc and yc:");
scanf("%d%d",&xc,&yc);
printf("Enter radius:");
scanf("%d",&r);
x=0;
y=r;
p=3-2*r;
do
{
delay(25);
putpixel(xc+x,yc+y,1);
putpixel(xc+y,yc+x,2);
putpixel(xc-x,yc+y,1);
putpixel(xc+y,yc-x,2);
putpixel(xc-y,yc-x,1);
putpixel(xc-x,yc-y,2);
putpixel(xc+x,yc-y,1);
putpixel(xc-y,yc+x,2);
if(p<0) {
p=p+4*x+6;
}
else
{
p=p+4*(x-y)+10;
y=y-1;
}
x=x+1;
}
while(x<y)
getch();
closegraph();
}
No comments:
Post a Comment