主题:H
FFKK
[专家分:1610] 发布于 2009-09-22 21:36:00
子程的全排列怎么做??????????????
回复列表 (共7个回复)
沙发
phile [专家分:2310] 发布于 2009-09-23 17:42:00
把排列部分放入子程序就行了
板凳
FFKK [专家分:1610] 发布于 2009-09-23 20:14:00
手动输入3个不为0的整数并打出全排列,给程序!!!!!!!!!(30分)[em7][em1]
3 楼
phile [专家分:2310] 发布于 2009-09-24 18:43:00
CLS
INPUT N
DIM A(N)
S=1
FOR I=1 TO N
INPUT A(I)
S=S*I
NEXT I
GOSUB 100
END
100
FOR I=1 TO S
FOR J=1 TO N
PRINT USING"#";A(I);
NEXT J
PRINT " ";
K=N
DO WHILE A(K)<=A(K-1)
K=K-1
LOOP
J=N
DO WHILE A(J)<=A(K-1)
J=J-1
LOOP
SWAP A(J),A(K-1)
FOR H=K TO N-1
FOR P=H+1 TO N
IF A(H)>A(P) THEN SWAP A(H),A(P)
NEXT P,H
NEXT I
RETURN
4 楼
FFKK [专家分:1610] 发布于 2009-09-24 21:02:00
不对
例输入1,2,3
输出 123,132,231,213,312,321
5 楼
phile [专家分:2310] 发布于 2009-09-26 12:39:00
CLS
INPUT N
DIM A(N)
S=1
FOR I=1 TO N
INPUT A(I)
S=S*I
NEXT I
FOR I=1 TO N-1
FOR J=I+1 TO N
IF A(I)>A(J) THEN SWAP A(I),A(J)
NEXT J,I
GOSUB 100
END
100
FOR I=1 TO S
FOR J=1 TO N
PRINT USING"#";A(I);
NEXT J
PRINT " ";
K=N
DO WHILE A(K)<=A(K-1)
K=K-1
LOOP
J=N
DO WHILE A(J)<=A(K-1)
J=J-1
LOOP
SWAP A(J),A(K-1)
FOR H=K TO N-1
FOR P=H+1 TO N
IF A(H)>A(P) THEN SWAP A(H),A(P)
NEXT P,H
NEXT I
RETURN
6 楼
FFKK [专家分:1610] 发布于 2009-09-27 20:10:00
不对
只能打印有一的而且只有两位
7 楼
phile [专家分:2310] 发布于 2009-09-28 18:59:00
????
我来回复