Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function GetMode(TEA: TExtendedArray): Extended;
- var
- h, i, f, m: Integer;
- begin
- h := High(TEA);
- case (h > -1) of
- True:
- case (h = 0) of
- False:
- begin
- Result := TEA[0];
- f := 1;
- m := 0;
- for I := 1 to High (TEA) do
- case (TEA[(I - 1)] = TEA[I]) of
- False:
- if (f <> 1) then
- begin
- if (f > m) then
- begin
- Result := TEA[(I - 1)];
- m := f;
- end;
- f := 1;
- end;
- True: Inc(f);
- end;
- case (m > 0) of
- True:
- if (f > m) then
- Result := TEA[h];
- False:
- if (f > 1) then
- Result := TEA[h];
- end;
- end;
- True: Result := TEA[0];
- end;
- False: Result := -1;
- end;
- end;
- var
- TEA: TExtendedArray;
- begin
- TEA := [0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5, 0.5, 0.6, 0.8, 0.8, 0.8, 0.8];
- WriteLn(GetMode(TEA));
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement