Итак, поскольку его старая библиотека и мой университет все еще используют его лицо ладони всем, кто заинтересован, я это выясню.
код:
#include <graphics.h>
#include <math.h>
#define G GREEN
#define X_AXIS 2
#define Y_AXIS 7
void draw_last(float direction)
{
double x = 0, y, px, py, cx = getmaxx()/2, cy = getmaxy()/2;
while (x <= X_AXIS && x >= -X_AXIS) {
/* Calculate y with given x */
y = 4 * pow(x, 7) - 3 * pow(x, 3) + 5;
/* Calculate coordoninates to display */
px = x * cx / X_AXIS + cx;
/* -cy because of origin point in window(top left corner) */
py = y * -cy / Y_AXIS + cy;
/* in case boundaries are passed */
if (py < 0 || py > getmaxy())
break;
if (x == 0) // only for first loop
moveto(px, py);
/* Draw segment line */
lineto(px, py);
/* update CP */
moveto(px, py);
x += direction;
delay(20);
}
}
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, NULL);
/* Draw the axis */
int cx = getmaxx()/2, cy = getmaxy()/2;
line(20, cy, getmaxx()-20, cy);
line(cx, 20, cx, getmaxy()-20);
outtextxy(cx, cy, "O");
outtextxy(20, cy, "-2");
outtextxy(getmaxx()-20, cy, "2");
outtextxy(cx, 20, "7");
outtextxy(cx, getmaxy()-20, "-7");
setcolor(GREEN);
setlinestyle(SOLID_LINE, 0, 2);
/* from x=0 ++ */
draw_last(0.01);
/* from x=0 -- */
draw_last(-0.01);
getch();
closegraph();
return (0);
}
вывод: ![enter image description here](https://i.stack.imgur.com/x3Fez.png)