Advertisement
LisunovaMaryna

lab1.4 delphi

Oct 3rd, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.38 KB | None | 0 0
  1. Program Lab;
  2.  
  3. Uses
  4.     System.SysUtils;
  5.  
  6. Var
  7.     Dlina, Dlina2, PolDliny, I, Peremen: Integer;
  8.     Massiv: Array Of Integer;
  9.     IsCorrect: Boolean;
  10.  
  11. Begin
  12.     Writeln('The program reverses the array.');
  13.     Write('Enter array length: ');
  14.     Repeat
  15.         Try
  16.             IsCorrect := True;
  17.             Read(Dlina);
  18.             If (Dlina < 0) Or (Dlina = 0) Then
  19.             Begin
  20.                 IsCorrect := False;
  21.                 Write('A negative value or zero was entered. Enter a valid value: ');
  22.             End;
  23.         Except
  24.             Begin
  25.                 Write('Symbols have been entered. Enter the number: ');
  26.                 IsCorrect := False;
  27.             End;
  28.          End;
  29.     Until IsCorrect;
  30.     SetLength(Massiv, Dlina);
  31.     Dlina2 := Dlina - 1;
  32.     Write(cout ');
  33.    For I := 0 To Dlina2 Do
  34.        Repeat
  35.            Try
  36.                IsCorrect := True;
  37.                Read(Massiv[I]);
  38.            Except
  39.                Begin
  40.                    Write('Symbols have been entered. Enter the number: ');
  41.                    IsCorrect := False;
  42.                End;
  43.            End;
  44.        Until IsCorrect;
  45.        PolDliny := (Dlina div 2) - 1;
  46.    For i := 0 To PolDliny Do
  47.    Begin
  48.        Peremen := Massiv[I];
  49.        Massiv[I] := Massiv[Dlina2 - I];
  50.        Massiv[Dlina2 - I] := Peremen;
  51.    End;
  52.    Write(Massiv);
  53. End.
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement