Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program Lab;
- Uses
- System.SysUtils;
- Var
- Dlina, Dlina2, PolDliny, I, Peremen: Integer;
- Massiv: Array Of Integer;
- IsCorrect: Boolean;
- Begin
- Writeln('The program reverses the array.');
- Write('Enter array length: ');
- Repeat
- Try
- IsCorrect := True;
- Read(Dlina);
- If (Dlina < 0) Or (Dlina = 0) Then
- Begin
- IsCorrect := False;
- Write('A negative value or zero was entered. Enter a valid value: ');
- End;
- Except
- Begin
- Write('Symbols have been entered. Enter the number: ');
- IsCorrect := False;
- End;
- End;
- Until IsCorrect;
- SetLength(Massiv, Dlina);
- Dlina2 := Dlina - 1;
- Write(cout ');
- For I := 0 To Dlina2 Do
- Repeat
- Try
- IsCorrect := True;
- Read(Massiv[I]);
- Except
- Begin
- Write('Symbols have been entered. Enter the number: ');
- IsCorrect := False;
- End;
- End;
- Until IsCorrect;
- PolDliny := (Dlina div 2) - 1;
- For i := 0 To PolDliny Do
- Begin
- Peremen := Massiv[I];
- Massiv[I] := Massiv[Dlina2 - I];
- Massiv[Dlina2 - I] := Peremen;
- End;
- Write(Massiv);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement