#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void circle1(int,int,int,int);
void circlealgo(int,int,int);
int main()
{
int radius,x,y;
int gd=DETECT,gm;
initgraph(&gd,&gm," ");
printf("\n Enter x:");
scanf("%d",&x);
printf("\n Enter y:");
scanf("%d",&y);
printf("\n Enter radius:");
scanf("%d",&radius);
circlealgo(x,y,radius);
getch();
closegraph();
return 0;
}
void circle1(int x0, int y0,int x1,int y1)
{
putpixel(x0+x1,y0+y1,123);
putpixel(x0-x1,y0+y1,90);
putpixel(x0+x1,y0-y1,75);
putpixel(x0-x1,y0-y1,200);
putpixel(x0+y1,y0+x1,500);
putpixel(x0-y1,y0+x1,45);
putpixel(x0+y1,y0-x1,178);
putpixel(x0-y1,y0-x1,12);
}
void circlealgo(int xcenter,int ycenter,int r)
{
int x=0;
int y=r;
int p=1-r;
circle1(xcenter,ycenter, x, y);
while(x<y)
{
x++;
if(p<0)
{
p=p+(2*x)+1;
}
else
{
y--;
p=p+(2*x)+1-(2*y);
}
circle1( xcenter, ycenter, x, y);
}
}
#include<conio.h>
#include<graphics.h>
void circle1(int,int,int,int);
void circlealgo(int,int,int);
int main()
{
int radius,x,y;
int gd=DETECT,gm;
initgraph(&gd,&gm," ");
printf("\n Enter x:");
scanf("%d",&x);
printf("\n Enter y:");
scanf("%d",&y);
printf("\n Enter radius:");
scanf("%d",&radius);
circlealgo(x,y,radius);
getch();
closegraph();
return 0;
}
void circle1(int x0, int y0,int x1,int y1)
{
putpixel(x0+x1,y0+y1,123);
putpixel(x0-x1,y0+y1,90);
putpixel(x0+x1,y0-y1,75);
putpixel(x0-x1,y0-y1,200);
putpixel(x0+y1,y0+x1,500);
putpixel(x0-y1,y0+x1,45);
putpixel(x0+y1,y0-x1,178);
putpixel(x0-y1,y0-x1,12);
}
void circlealgo(int xcenter,int ycenter,int r)
{
int x=0;
int y=r;
int p=1-r;
circle1(xcenter,ycenter, x, y);
while(x<y)
{
x++;
if(p<0)
{
p=p+(2*x)+1;
}
else
{
y--;
p=p+(2*x)+1-(2*y);
}
circle1( xcenter, ycenter, x, y);
}
}
No comments:
Post a Comment