Помогите перевести с паскаля на с++ const eps = 1e-4;

function pow(x : Real; k : Integer) : Real;
var r : Real;
begin
r := 1;
while k > 1 do
begin
Dec(k);
r := r * x;
end;
pow := r;
end;

function pRoot(x : Real; k : Integer) : Real;
var y, y0 : Real;
begin
y := 1;
repeat
y0 := y;
y := y + (x / pow(y, k-1) - y) / k;
until abs(y - y0) < eps;
pRoot := y;
end;

var a : Real;
begin
ReadLn(a);
WriteLn((pRoot(a,3) - pRoot(a*a+1,6))/(1 + pRoot(3+a,7)) :0:5);
end.
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Copyright © 2024 SCHOLAR.TIPS - All rights reserved.