binsrc.for
来自「This Source-Navigator, an IDE for C/C++/」· FOR 代码 · 共 40 行
FOR
40 行
SUBROUTINE BINSRC(KELEM,KLIST,NLIST,IPOS,LAST)*-----------------------------------------------------------------------**---Purpose: finds number in sorted list (ascending)* with binary search.**---Input* KELEM number to be looked up* KLIST table* NLIST length of table**---Output* IPOS = 0: name not in table* > 0: position in table* LAST for IPOS=0, position behind which number belongs***----------------------------------------------------------------------- DIMENSION KLIST(*) IPOS=0 LAST=0 N=NLIST IF(N.GT.0) THEN KPOS=0 10 M=(N+1)/2 LAST=KPOS+M IF (KELEM.LT.KLIST(LAST)) THEN N=M LAST=LAST-1 IF (N.GT.1) GOTO 10 ELSEIF (KELEM.GT.KLIST(LAST)) THEN KPOS=LAST N=N-M IF (N.GT.0) GOTO 10 ELSE IPOS=LAST ENDIF ENDIF END
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?