#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdlib.h>
void setpixel1(int,int,int,int);
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm," ");
int xc,yc,a,b;
int my,my1,my2,my3,x,y,p,fx,fy;
printf("\n\n Enter xc:");
scanf("%d",&xc);
printf("\n\n Enter yc:");
scanf("%d",&yc);
printf("\n\n Enter major axis a:");
scanf("%d",&a);
printf("\n\n Enter minor axis b:");
scanf("%d",&b);
x=0;
y=b;
my=a*a;
my1=b*b;
my2=aa*2;
my3=bb*2;
fx=0;
fy=my*b;
p=(my1)-(my*b)+(0.25*my)
setpixel1(xc,yc,x,y);
while(fx<fy)
{
x++;
fx=fx+my3;
if(p<0)
{
p=p+fx+my1;
}
else
{
y--;
fy=fy-my2;
p=p+fx+my1-fy;
}
setpixel1(xc,yc,x,y);
}
p=(my1*(x+0.5)*(x+0.5))+(my*(y-1)*(y-1))-(my*my1);
while(y>0)
{
y--;
fy=fy-my2;
if(p>=0)
{
p=p+my-fy;
}
else
{
x++;
fx=fx+my3;
p=p+my+fx-fy;
}
setpixel1(xc,yc,x,y);
}
getch();
closegraph();
return 0;
}
void setpixel1(int xc, int yc, int x, int y)
{
putpixel(xc+x, yc+y,11);
putpixel(xc-x, yc+y,11);
putpixel(xc+x, yc-y,11);
putpixel(xc-x, yc-y,11);
}
No comments:
Post a Comment