function GetMaxIndex(Int: array of Integer): string;type TItem = record v, C: integer; end; PItem = ^TItem;var list: Tlist; L, H, ti: integer; procedure AddItem(const v, c: Integer); var p: PItem; i: integer; begin New(p); p.v := v; p.C := c; if list.Count = 0 then list.Add(p) else begin if c >= pitem(list[0]).c then list.Insert(0, p) else for i := list.Count - 1 downto 0 do begin if c <= pitem(list).C then begin list.Insert(i + 1, p); break; end; end; end; end; function VExist(const v: Integer): boolean; var i: integer; begin result := false; if list.Count > 0 then for i := 0 to list.Count - 1 do if v = pitem(list).v then begin result := true; break; end; end; procedure CheckItem(const v: Integer); var i, c: integer; begin c := 0; if not VExist(v) then begin for i := l to h do if Int = v then Inc(c); AddItem(v, c); end; end;begin L := Low(Int); H := High(Int); if H - L >= 1 then begin list := Tlist.Create; try for ti := l to h do CheckItem(int[ti]); for ti := 0 to list.Count - 1 do result := result + 'Value:'+ inttostr( pitem(list[ti]).v) + ' Count:' + IntToStr(pitem(list[ti]).C) + #13#10; finally while list.count > 0 do begin dispose(PItem(List[list.count -1])); list.delete(list.count - 1); end; list.Free; end; end;end;procedure TForm1.btn1Click(Sender: TObject);var a: array[0..12] of Integer; i: integer;begin a[0]:= 12; a[1]:= 12; a[5]:= 12; a[3]:= 2; a[2]:= 2; a[4]:= 5; a[6]:= 20; a[7]:= 20; a[8]:= 200; a[9]:= 222; a[10]:= 222; a[11]:= 222; a[12]:= 222; mmo1.text :=GetMaxIndex(a);end;result:Value:222 Count:4Value:12 Count:3Value:2 Count:2Value:20 Count:2Value:5 Count:1Value:200 Count:1