Advertisement
MaksNew

Untitled

Feb 22nd, 2021
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.60 KB | None | 0 0
  1. type
  2.     Human = record
  3.         Age: Byte;
  4.         LastName: String[20];
  5.     end;
  6.     Peoples = array of Human;
  7.  
  8. function PeoplesMaxAge(Peopless: Peoples): Peoples;
  9. var
  10.     I, Count: Byte;
  11.     MaxAge: Integer;
  12.     MaxAgePeoples: Peoples;
  13. begin
  14.     Count := 0;
  15.     MaxAge := -1;
  16.     for I := 0 to Length(Peopless)-1 do
  17.         if (Peopless[I].Age >= MaxAge) then
  18.         begin
  19.             Inc(Count);
  20.             SetLength(MaxAgePeoples, Count);
  21.             MaxAge := Peopless[I].Age;
  22.             MaxAgePeoples[Count-1] := Peopless[I];
  23.         end;
  24.     PeoplesMaxAge := MaxAgePeoples;
  25. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement