#include #include #include #include #include #include #include int GraphDriver; /* The Graphics device driver */ int GraphMode, ErrorCode; void Initialize(void) { int xasp, yasp; /* Used to read the aspect ratio*/ GraphDriver = DETECT; /* Request auto-detection */ initgraph( &GraphDriver, &GraphMode, "" ); ErrorCode = graphresult(); /* Read result of initialization*/ if( ErrorCode != grOk ){ /* Error occured during init */ printf(" Graphics System Error: %s\n", grapherrormsg( ErrorCode ) ); exit( 1 ); } } void assi() { line(0,239,639,239); line(319,0,319,479); } void punto(float x, float y) { putpixel(int(x)+319,int(239-y),2); } void cerchio(float x, float y, int r) { circle(int(x)+319,int(239-y),r); } void testo(float x, float y, char *s) { outtextxy(int(x)+319,int(239-y),s); } int segno(float y) { if(y>0) return 1; if(y==0) return 0; if(y<0) return -1; } void main() { int i; float x,y; int segnoy; Initialize(); assi(); y=0.1F*(-100)*(-100)-16; for (x=-100; x<=100 ; x=x+0.1F) { segnoy=segno(y); y=0.1F*x*x-16; if (segnoy!=segno(y)) cerchio(x,y,5); punto(x,y); delay(10); } getch(); }