You are on page 1of 3

Thut ton v Hyperbol

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
void InitGraph()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error : %s\n", grapherrormsg(errorcode));
getch();
exit(1);
}
}
void put4pixel(int x, int y)
{
int xx, yy, color;
xx=getmaxx()/2;
yy=getmaxy()/2;
putpixel(x+xx,y+yy,12);
putpixel(-x+xx,y+yy,5);
putpixel(x+xx,-y+yy,4);
putpixel(-x+xx,-y+yy,11);
delay(20);
}
void Hyperbol()
{
float a=70, b=60,p,c1,c2;
float x,y;

x=a;y=0;
put4pixel(x,y);
p=4*a*b*b+b*b-4*a;
while((a*a-b*b)*x*x<=a*a*a*a)
{
if(p<0)
{
p+=8*b*b*x-8*a*a*y+8*b*b-12*a*a;
x++;
}
else
p=p-8*a*a*y-12*a*a;
y++;
put4pixel((int)x,(int)y);
}
while(x<=200)
{
if(p<0)
p+=8*b*b*x+12*b*b;
else
{
p+ =8*b*b*x-8*a*a*y+12*b*b-8*a*a;
y++;
}
x++;
put4pixel((int)x,(int)y);
}
void main()
{
InitGraph();
Hyperbol();
getch() ;
closegraph();
}

BEGIN
p = 4A2B + B2 +
A2
x = A; y = 0;
Put4pixel(x,y,color
);
No

(A2-B2)x2
A4
Yes
p<0

x
200

No

Yes
No

Yes
p=p+8B2x
8A2y+8B2+12A2;
x=x+1;

y = y + 1;
Put4pixel(x,y,col
or);

LU HYPERBOL

p=p - 8A2y - 12A2;

p<0
Yes
p=p+8B2x +
12B2;

x = x +1;
Put4pixel(x,y,col
or);

No

END
p=p+8B2x+ 12B2 8A2y
8A2;
y = y + 1;

You might also like