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);
- if n > 0 then
- IsCorrect := True
- else
- Writeln('Верхняя граница должна быть больше 0')
- except
- Writeln('Верхняя граница суммирования должна быть числом')
- end;
- Until IsCorrect;
- for i := 1 to n do
- if i mod 2 = 1 then
- Output := Output - 1/(2*i)
- else
- Output :=Output + 1/(2*i);
- WriteLn('Сумма равна ',floattostr(Output));
- Readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement