home *** CD-ROM | disk | FTP | other *** search
- Function binary(look : integer) :integer;{Find binary way}
- {Look is the variable you're looking for}
- var
- temp, {The number}
- b,mid,z, {Front and end}
- f:integer; {For next loops}
- Begin
-
- b:=1; {Set variables}
- z:=count;
- temp:=-1;
-
- repeat
-
- mid:=(b+z) div 2; {Middle}
-
- if a[mid].id=look then temp:=a[mid].inv
- else if a[mid].id<look then b:=mid+1
- else if a[mid].id>look then z:=mid-1;
-
- until (temp>-1) or (b>z);
-
- binary:=temp;
-
- End;
-