#include<stdio.h>
#include<graphics.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
int r,pk,xc,yc,x,y,pk1;
cout<<"enter the coordinates of center:";
cin>>xc>>yc;
cout<<"enter the radius:";
cin>>r;
pk=1-r;
x=0;
y=r;
while((x<=y))
if(pk<0)
{
x++;
putpixel(x+xc,y+yc,RED);
putpixel(-y+xc,x+yc,RED);
putpixel(x+xc,-y+yc,RED);
putpixel(-y+xc,-x+yc,RED);
putpixel(-x+xc,-y+yc,RED);
putpixel(-x+xc,y+yc,RED);
putpixel(y+xc,-x+yc,RED);
putpixel(y+xc,x+yc,RED);
pk=pk+(2*x)+1;
}
else
{
x++;
y--;
putpixel(x+xc,y+yc,RED);
putpixel(-y+xc,x+yc,RED);
putpixel(x+xc,-y+yc,RED);
putpixel(-y+xc,-x+yc,RED);
putpixel(-x+xc,-y+yc,RED);
putpixel(-x+xc,y+yc,RED);
putpixel(y+xc,-x+yc,RED);
putpixel(y+xc,x+yc,RED);
pk=pk+(2*x)-(2*y)+1;
}
getch();
closegraph();
}
#include<graphics.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"C:\\TURBOC3\\BGI");
int r,pk,xc,yc,x,y,pk1;
cout<<"enter the coordinates of center:";
cin>>xc>>yc;
cout<<"enter the radius:";
cin>>r;
pk=1-r;
x=0;
y=r;
while((x<=y))
if(pk<0)
{
x++;
putpixel(x+xc,y+yc,RED);
putpixel(-y+xc,x+yc,RED);
putpixel(x+xc,-y+yc,RED);
putpixel(-y+xc,-x+yc,RED);
putpixel(-x+xc,-y+yc,RED);
putpixel(-x+xc,y+yc,RED);
putpixel(y+xc,-x+yc,RED);
putpixel(y+xc,x+yc,RED);
pk=pk+(2*x)+1;
}
else
{
x++;
y--;
putpixel(x+xc,y+yc,RED);
putpixel(-y+xc,x+yc,RED);
putpixel(x+xc,-y+yc,RED);
putpixel(-y+xc,-x+yc,RED);
putpixel(-x+xc,-y+yc,RED);
putpixel(-x+xc,y+yc,RED);
putpixel(y+xc,-x+yc,RED);
putpixel(y+xc,x+yc,RED);
pk=pk+(2*x)-(2*y)+1;
}
getch();
closegraph();
}
No comments:
Post a Comment