#include <stdlib.h> //График
#include <iostream.h>
#include <math.h>
#include <conio.h>
#include <graphics.h>
float f(float x);
void main()
{
сonst float a=0, b = 2*3.14, h = 0.1;
const int h1 = 5, x0 = 60, y0 = 240, M = 50;
int gdriver = DETECT, gmode, errorcode;
int x1, y1;
float x,y;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
if (errorcode != grOk)
{
cout<<"Ошибка"<<grapherrormsg(errorcode);
cout<<"\n Нажмите на любую клавишу";
getch();
exit(1);
}
setbkcolor(1);
setcolor(14);
line(20, y0, 600, y0);
line(x0, 440, x0, 20);
x=a;
x1 = x0 + M*x;
y = f(x);
y1 = y0 - M*y;
moveto(x1, y1);
setcolor(15);
do
{
y = f(x); y1 = y0-(M*y);
lineto(x1, y1);
x1 += h1; x=x+h;
}
while (x <= b);
settextstyle(0, 0, 1);
outtextxy (60, 245, "0");
outtextxy (360, 245, "6.3");
settextxtyle(0, 0, 2);
outtextxy (100, 380, "График функции y=2sin2x+1");
getch(); closegraph();
}
float f(float x)
{
float func;
func = 2 * sin (2*x) + 1;
return func;
}