Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Lab1_2;
- uses System.SysUtils;
- var
- N,I : Integer;
- Output : Double;
- IsCorrect : Boolean;
- begin
- IsCorrect := False;
- Repeat
- Writeln('Введите верхнюю границу суммирования');
- try
- Readln(N);
- IsCorrect := True
- except
- Writeln('Верхняя граница суммирования должна быть числом');
- end;
- if (N < 1) and IsCorrect then
- begin
- Writeln('Верхняя граница должна быть больше 0');
- IsCorrect := False;
- end
- Until IsCorrect;
- for I := 1 to N do
- if I mod 2 = 1 then
- Output := Output - 1/I
- else
- Output := Output + 1/I;
- Output := Output/2;
- WriteLn('Сумма равна ',FloatToStr(Output));
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement