Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program Задание2;
- Uses System.SysUtils;
- Var
- N, Sum, I: Integer;
- IsCorrect: Boolean;
- Begin
- IsCorrect := False;
- Write('Введите N (количество суммируемых элементов): ');
- Repeat
- Try
- Readln(N);
- If N < 0 Then
- Writeln('Введите натуральное число!')
- Else
- IsCorrect := True;
- Except
- Writeln('Введите натуральное число!');
- End;
- Until IsCorrect;
- For I := 1 To N Do
- If I Mod 2 = 1 Then
- Sum := Sum - I * I
- Else
- Sum := Sum + I * I;
- Writeln('Значение искомой суммы: ', Sum);
- Readln(N);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement