没有校对,不知算法对不对
图片附件: 游客没有浏览图片的权限,请
登录 或
注册
程序代码:
use bb in 0
use pmax in 0
SELECT pmax
BLANK FIELDS mmax ALL
SELECT bb
COPY TO ARRAY a100 NEXT 100 && 第1个100行
pmax(@a100)
SELECT bb
SKIP
SCAN REST
** 下一个100行
SCATTER TO a1 && 取bb一行存入a1
ADEL(a100,1) && 删除a100第1行
ACOPY(a1, a100, 1, -1, AELEMENT(a100,100,1)) && 将a1写入a100最后一行
pmax(@a100)
ENDSCAN
SELECT * FROM pmax
RETURN
FUNCTION k2k3(k2,k3,n1) && 最大值、最次大值
IF n1 > k2
k2 = n1
ELSE
IF n1 > k3
k3 = n1
ENDIF
ENDIF
ENDFUNC
FUNCTION pmax(a100)
FOR nCol=2 TO ALEN(a100,2)
n1 = 0
k2 = 0
k3 = 0
krow = 0 &&非空行数
FOR nRow=1 TO ALEN(a100,1)
IF EMPTY(a100[nRow,nCol])
n1 = n1 + 1
ELSE
k2k3(@k2,@k3,@n1)
n1 = 0
krow = krow + 1
ENDIF
ENDFOR
k1 = n1 &&列最后行的值
k2k3(@k2,@k3,@n1)
IF k1==k2 AND k1>0 AND krow>20 AND k1<7 &&求第2大值,与最大值比较
IF INLIST(k2-k3,1,2) &&在pmax对应行标注
SELECT pmax
GO a100[100,1]
REPLACE mmax WITH "MMAX"
EXIT
ENDIF
ENDIF
ENDFOR
ENDFUNC