Вопрос задан 20.07.2023 в 06:05. Предмет Информатика. Спрашивает Фролова Арина.

Подскажите почему ошибка: const x=0.2; y :array[1..9]of real=(0.1,0.2,-0.3,-0.04,5,6,-7.03,8,9);

function t(u:real):real; begin t:=sin(u)+cos(u); end; function p(a,b:integer; s:array[1..9] of real):real; var i:integer; d:real; begin d:=1; for i:= a to b do d:=d*v[i]; p:=d; end; Begin cls; writeln('z(x,y)=',exp(ln(t(x))*3)/p(y,1,9)+sqr(p(y,1,9))/exp(ln(t(x))*2/3)); End.
0 0
Перейти к ответам

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

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

Ответ:

Объяснение:

Тут смысла нет передавать массив в качестве параметра, т.к. он описан как const .

Текст будет примерно такой

const x=0.2;

 y :array[1..9]of real=(0.1,0.2,-0.3,-0.04,5,6,-7.03,8,9);

function t(u:real):real;

begin

t:=sin(u)+cos(u);

end;

function p(a,b:integer):real;

var i:integer; d:real;

begin

d:=1;

for i:= a to b do

d:=d*y[i];

p:=d;

end;

Begin

cls;

writeln('z(x,y)=',exp(ln(t(x))*3)/p(1,9)+sqr(p(1,9))/exp(ln(t(x))*2/3):6:4);

readln;

End.

Если нужно массив передать в функцию, то его описывают как новый тип переменной и передают

Вот так, например:

const z=9;

type mas=array[1..z] of integer;

var

u :mas;

i:integer;

// Вывод массива на экран

// a -массив n-размер,text - что хотим написать

procedure showmas(b:mas;n:integer;text:string);

var

i:integer;

begin

writeln(text);

for i:=1 to n  do

write(b[i],' ');

readln;

end;

begin

for i:=1 to 9 do

u[i]:= random(20);

showmas(u,10,'Исходный массив u');

end.

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

The code you provided contains a few errors that need to be addressed. I'll point out the mistakes and provide the corrected version of the code:

  1. Issue: In the function p(a, b: integer; s: array[1..9] of real): real;, the variable v is used in the loop, but it is not declared or initialized anywhere. Correction: Replace v[i] with s[i].

  2. Issue: The variable y is declared as an array of real numbers, but in the calculation of p(y, 1, 9), it is being treated as an array of integers. Correction: Change the parameter types of p function from integer to real for a and b.

  3. Issue: The exp and ln functions require the Math unit to be included in the code. Correction: Add uses Math; at the beginning of the code to include the Math unit.

Here's the corrected version of the code:

pascal
uses Math; const x = 0.2; y: array[1..9] of real = (0.1, 0.2, -0.3, -0.04, 5, 6, -7.03, 8, 9); function t(u: real): real; begin t := sin(u) + cos(u); end; function p(a, b: real; s: array[1..9] of real): real; var i: integer; d: real; begin d := 1; for i := round(a) to round(b) do d := d * s[i]; p := d; end; begin writeln('z(x,y) = ', exp(ln(t(x)) * 3) / p(1, 9, y) + sqr(p(1, 9, y)) / exp(ln(t(x)) * 2 / 3)); end.

With these corrections, the code should now work correctly and produce the desired output.

0 0

Похожие вопросы

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

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

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