回复 10楼 吹水佬
请教先生,您的运行代码是怎样的,能找到符合要求的,我运行了几天还是没有找到啊
先获取1...32中任选16个的组合作为记录号再求和比较。
因总共有6亿多个组合,一个文件存放不下,要分段处理。
我的机上试1...4开头的记录组合分了4次来处理,5开头的一次就可以。
试算代码:
程序代码:
ASTACKINFO(a程序) SET DEFAULT TO ADDBS(JUSTPATH(a程序[2])) CLEAR SET TALK OFF CLOSE DATABASES ALL m = 32 n = 16 k1 = 1 && 1...17,开头记录号 USE 原表 IN 0 IF FILE("记录表.dbf") USE 记录表 IN 0 ELSE CREATE TABLE 记录表 (记录号列表 C(48)) ENDIF CREATE CURSOR dd (ff I) FOR i = 1 TO m APPEND BLANK ENDFOR REPLACE ff WITH RECNO() ALL szSELECT = "d1.ff" szFROM = "dd d1" szWHERE = "d1.ff<d2.ff" FOR i = 2 TO n szSELECT = szSELECT + ",d" + TRANSFORM(i) + ".ff" szFROM = szFROM + ",dd d" + TRANSFORM(i) IF i > 2 szWHERE = szWHERE + " AND d" + TRANSFORM(i-1) + ".ff<d" + TRANSFORM(i) + ".ff" ENDIF ENDFOR T1 = DATETIME() FOR k2 = k1+1 TO 18 ? k2 FOR k3 = k2+1 TO 19 FOR k4 = k3+1 TO 20 szWHERE2 = "d1.ff=" + TRANSFORM(k1) + " AND " +; "d2.ff=" + TRANSFORM(k2) + " AND " +; "d3.ff=" + TRANSFORM(k3) + " AND " +; "d4.ff=" + TRANSFORM(k4) + " AND " + szWHERE EXECSCRIPT("SELECT " + szSELECT + " FROM " + szFROM + " WHERE " + szWHERE2 + " INTO CURSOR tmp") SELECT tmp SCAN STORE 0 TO n列1, n列2, n列3, n列4 FOR i = 1 TO n nRec = EVALUATE(FIELD(i, "tmp")) GO nRec IN "原表" n列1 = n列1 + 原表.列1 n列2 = n列2 + 原表.列2 n列3 = n列3 + 原表.列3 n列4 = n列4 + 原表.列4 ENDFOR IF (n列1 == n列2) AND ((n列3 + 7864320) == n列4) APPEND BLANK IN "记录表" sz记录号列表 = TRANSFORM(EVALUATE(FIELD(1, "tmp"))) FOR i = 2 TO n sz记录号列表 = sz记录号列表 + "," + TRANSFORM(EVALUATE(FIELD(i, "tmp"))) ENDFOR REPLACE 记录号列表 WITH sz记录号列表 IN "记录表" ENDIF ENDSCAN SELECT tmp USE ENDFOR ENDFOR ENDFOR ? DATETIME() - T1 SELECT 记录表 BROWSE CLOSE DATABASES ALL RETURN
[ 本帖最后由 吹水佬 于 2015-9-21 10:42 编辑 ]