Предмет: Информатика, автор: ruslanarihin

прооошу помогите перевести этот код delphi в паскаль,плиииз





program TaskFormula;
uses
var x, a, xn, xk, dx, sum, multiplNegative: real;   
countNegative: integer;   
 j,m,f:real;   
y: Real;
begin 
writeln('a --> '); 
Read(a); 
writeln(' xn --> '); 
Read(xn); 
writeln(' xk --> '); 
Read(xk); 
writeln(' dx --> '); 
Read(dx);
  sum := 0; 
multiplNegative := 1; 
 countNegative := 0; 
 x := xn;
  While (x <= xk) do    begin    if (a+x < 0)  then    begin     f:=(a+x)*-1;     
f:=ln(f)*(-1);   
  j:= RoundTo(abs(a-sqr(x)) * f,-5);  
  end   
else     
 j:= RoundTo(abs(a-sqr(x)) * ln(a+x),-5);    
m:= Power(sqr(x),1/3)+ Power(a,1/5); 
    if j<0 then      begin      j:=j*(-1);     
 j:= Power(j, 1/3);     
 j:=j*(-1);   
end   
else     
 j:= Power(j, 1/3);
    y:= RoundTo(j/m,-5);   
write('x= ',x:5:3,'   ');   
 writeln('y= ',y:7:5);     
if y<0 then     
begin     
sum := sum + y;     
multiplNegative := multiplNegative * y;     
inc(countNegative);      
end;   
x:= x + dx;   
 end;     
writeln; 
 writeln('  y = ',countNegative); 
 writeln('y = ',sum:7:5); 
writeln(' y = ',multiplNegative:7:5);
  Readln;
end.

Ответы

Автор ответа: HRAshton
0
var
  y, x, a, xn, xk, dx, sum, multiplNegative: real
  countNegative: integer
  j, m, f: real;

begin
  write('a --> '); 
  Read(a); 
  write(' xn --> '); 
  Read(xn); 
  write(' xk --> '); 
  Read(xk); 
  write(' dx --> '); 
  Read(dx);
  sum := 0; 
  multiplNegative := 1; 
  countNegative := 0; 
  x := xn;
  while (x <= xk) do 
  begin
    if (a + x < 0) then begin
      f := (a + x) * -1; 
      f := ln(f) * (-1); 
      j := Round(abs(a - sqr(x)) * f * 100000) / 100000; 
    end 
    else 
      j := Round(abs(a - sqr(x)) * ln(a + x) * 100000) / 100000; 
    m := Power(sqr(x), 1 / 3) + Power(a, 1 / 5); 
    if j < 0 then begin
      j := j * (-1); 
      j := Power(j, 1 / 3); 
      j := j * (-1); 
    end 
    else 
      j := Power(j, 1 / 3);
    y := Round(j / m * 100000) / 100000; 
    write('x= ', x:5:3, ' '); 
    writeln('y= ', y:7:5); 
    if y < 0 then 
    begin
      sum := sum + y; 
      multiplNegative := multiplNegative * y; 
      inc(countNegative); 
    end; 
    x := x + dx; 
  end; 
  writeln; 
  writeln(' y = ', countNegative); 
  writeln('y = ', sum:7:5); 
  writeln(' y = ', multiplNegative:7:5);
  Readln;
end.
Автор ответа: ruslanarihin
0
для чего вот это действие
Автор ответа: HRAshton
0
RoundTo в Pascal нет, посему таким очень хитрым колдунством округляем по 5 знаков:)
Похожие вопросы