请教整行全排列问题
请教先生:我想将表内的整行作不同的排列,现表中只有5行,按全排列知识排成后的结果共应该是120行,可我用代码运行下来怎么会有201600行,请先生指点(代码及表在附件中),谢谢
材料.rar
(1.28 KB)
** ** 从n个数中任取m个数的排列 ** 当m=n时所有的排列叫全排列 ** n = 5 m = n CREATE CURSOR tt (ni I) FOR i = 1 TO n INSERT INTO tt Values(i) ENDFOR sSELECT = "" sFROM = "" sWHERE = "" FOR i = 1 TO m sSELECT = sSELECT + ",a"+TRANSFORM(i)+".ni 列"+TRANSFORM(i) sFROM = sFROM + ",tt a"+TRANSFORM(i) IF i < m ss = "" FOR j = i TO m ss = ss + ",a"+TRANSFORM(j)+".ni" ENDFOR sWHERE = sWHERE + " AND !INLIST("+SUBSTR(ss,2)+")" ENDIF ENDFOR EXECSCRIPT("SELECT " + SUBSTR(sSELECT,2) + " " +; "FROM " + SUBSTR(sFROM,2) + " " +; "WHERE " + SUBSTR(sWHERE,6) + " " +; "INTO CURSOR tmp") BROWSE NOWAIT MESSAGEBOX("从"+TRANSFORM(n)+"个数中任取出"+TRANSFORM(m)+"个数的排列共 " + TRANSFORM(RECCOUNT()) + " 种")