字符串操作,遍历组合,可否使用For语句?最近VFP块忘光了
AA='040506'最后实现第一个字符串组合,输出:04#05#06#04+05#04+06#05+06#04+05+06
输出第二个:04*05#04*06#05*06#04*05*06
记得使用For ENdfor是不是可以容易实现?
CLEAR AA = '040506' LOCAL la[3] FOR lnj = 1 TO 3 la[lnj] = SUBSTR(aa, lnj*2 - 1, 2) ENDFOR STORE "" TO c1, c2, c3, c4, c5 FOR lnj = 1 TO 3 IF BETWEEN(lnj, 1, 3) c1 = c1 + "#" + la[lnj] c5 = c5 + "+" + la[lnj] ENDIF IF INLIST(lnj, 1, 2) c2 = c2 + "+" + la[lnj] ENDIF IF INLIST(lnj, 1, 3) c3 = c3 + "+" + la[lnj] ENDIF IF INLIST(lnj, 2, 3) c4 = c4 + "+" + la[lnj] ENDIF ENDFOR ? "第一个字符串组合=" + SUBSTR(c1, 2) + "#" + SUBSTR(c2, 2) + "#" + SUBSTR(c3, 2) + "#" + SUBSTR(c4, 2) + "#" + SUBSTR(c5, 2) STORE "" TO c1, c2, c3, c4 FOR lnj = 1 TO 3 IF BETWEEN(lnj, 1, 3) c4 = c4 + "*" + la[lnj] ENDIF IF INLIST(lnj, 1, 2) c1 = c1 + "*" + la[lnj] ENDIF IF INLIST(lnj, 1, 3) c2 = c2 + "*" + la[lnj] ENDIF IF INLIST(lnj, 2, 3) c3 = c3 + "*" + la[lnj] ENDIF ENDFOR ? "第二个字符串组合=" + SUBSTR(c1, 2) + "#" + SUBSTR(c2, 2) + "#" + SUBSTR(c3, 2) + "#" + SUBSTR(c4, 2)