Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function IsPalindrome(Arr: Array Of Integer; left, right : Integer) : Boolean;
- var
- IsCorrect : Boolean;
- begin
- if (left >= right) then
- IsCorrect := True
- else
- begin
- IsCorrect := (Arr[left] = Arr[right]) and IsPalindrome(Arr, left+1, right-1);
- end;
- IsPalindrome := IsCorrect;
- end;
- procedure FindPalindrome(Arr : Array Of Integer; var I, J : Integer);
- var
- IndexI, IndexJ : Integer;
- MaxI, MaxJ : Integer;
- begin
- MaxI := 0;
- MaxJ := 0;
- For IndexI := 0 To High(Arr) Do
- Begin
- For IndexJ := High(Arr) Downto IndexI Do
- Begin
- If IsPalindrome(Arr, IndexI, IndexJ) Then
- Begin
- If(IndexJ - IndexI) > (MaxJ - MaxI) Then
- Begin
- MaxI := IndexI;
- MaxJ := IndexJ;
- End;
- End;
- End;
- End;
- I := MaxI;
- J := MaxJ;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement