Advertisement
electricmaster

fetchHighest()

Jan 26th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.65 KB | None | 0 0
  1. function fetchHighest(data: people): integer; // returns salesman id
  2. var
  3.   i: integer;
  4.   t: array[0..1] of integer;
  5. begin
  6.   t[0] := 0;
  7.   t[1] := 0;
  8.   for i := 1 to length(data) do begin
  9.     if data[i].score > t[1] then begin
  10.       t[0] := i;
  11.       t[1] := data[i].score;
  12.     end;
  13.   end;
  14.   Result := t[0];
  15. end;
  16.  
  17. function fetchLowest(data: people): integer;
  18. var
  19.   i: integer;
  20.   t: array[0..1] of integer;
  21. begin
  22.   t[0] := fetchHighest(data);
  23.   t[1] := data[t[0]].score;
  24.   for i := 1 to length(data) do begin
  25.     if data[i].score < t[1] then begin
  26.       t[0] := i;
  27.       t[1] := data[i].score;
  28.     end;
  29.   end; // for
  30.   Result := t[0];
  31. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement