Вопрос задан 03.05.2019 в 20:48. Предмет Информатика. Спрашивает Vishnikov Dima.

Составьте программу,которая строит график зависимости y(x)=0,5x•cos2x на промежутке[-12;12]

помоггите пожалуйста.. всё в паскале ABC
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Мисюра Лёня.

uses GraphABC;

type FUN = function (x: real): real;

function f(x: real): real;
begin
f:=0.5*x*cos(2*x);
end;

// l (logical) - логические координаты
// s (screen) - физические координаты
procedure drawGraph(x1,x2,y1,y2: real; f: FUN);
var
xl,xl0,wl,yl,yl0,hl: real;
xs0,ws,ys0,hs: integer;
function LtoSx(xl: real): integer;
begin
Result:=round(ws/wl*(xl-xl0)+xs0);
end;
function LtoSy(yl: real): integer;
begin
Result:=round(hs/hl*(yl-yl0)+ys0);
end;
function StoLx(xs: integer): real;
begin
Result:=wl/ws*(xs-xs0)+xl0;
end;
var xi: integer;
begin // drawGraph
xs0:=0; ys0:=WindowHeight;
ws:=WindowWidth;
hs:=WindowHeight;
xl0:=x1;
yl0:=y1;
wl:=x2-x1;
hl:=-(y2-y1);
MoveTo(xs0,LtoSy(f(StoLx(xs0))));
for xi:=xs0+1 to xs0+ws do
LineTo(xi,LtoSy(f(StoLx(xi))));
end;

begin // program
SetWindowCaption('График функции');
drawGraph(-12,12,-23,23,f);
end.

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Program to Plot a Graph in Pascal

To create a program that plots the graph of the function y(x) = 0.5x * cos(2x) on the interval [-12;12] in Pascal, you can use the following code:

```pascal program GraphPlotter; uses Crt, Graph;

const xmin = -12; xmax = 12; ymin = -10; ymax = 10;

var gd, gm, x: integer; y: real;

begin gd := Detect; InitGraph(gd, gm, '');

SetColor(15); Line(320, 0, 320, 480); Line(0, 240, 640, 240);

SetColor(14); x := xmin; MoveTo(320 + Trunc(x * 20), 240 - Trunc(0.5 * x * Cos(2 * x) * 20)); while x <= xmax do begin y := 0.5 * x * Cos(2 * x); LineTo(320 + Trunc(x * 20), 240 - Trunc(y * 20)); x := x + 0.1; end;

ReadLn; CloseGraph; end. ```

This program uses the Pascal graphics library to plot the graph of the function y(x) = 0.5x * cos(2x) on the interval [-12;12]. The graph is displayed in a window, and the x and y axes are drawn to provide a visual representation of the function.

I hope this helps! If you have any further questions or need additional assistance, feel free to ask.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос