Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program laba_1_3;
- Uses System.SysUtils;
- var X, Y, Y0, Eps: single;
- N: integer;
- IsInCorrect : boolean;
- begin
- repeat
- IsInCorrect := True;
- Writeln('Введите EPS (EPS > 0): ');
- Try
- readln(Eps);
- Except
- Writeln ('Пожалуйста, введите число.');
- IsInCorrect := False;
- End;
- if (IsInCorrect) and (Eps <=0 ) then
- begin
- Writeln ('Число Эпсилон должно быть положительным.');
- IsIncorrect := False;
- end;
- until (IsInCorrect);
- repeat
- IsInCorrect := true;
- Writeln('Введите x: ');
- Try
- readln(X);
- Except
- Writeln ('Пожалуйста, введите число.');
- IsInCorrect := false;
- end;
- until (IsInCorrect);
- Y0 := 1;
- N := 0;
- repeat
- inc(N);
- Y := Y0;
- Y0 := 0.5 * (Y + X / Y);
- until abs(Y - Y0) <= Eps;
- write('Корень из x = ', Y0, ', Количество итераций: ', N);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement