谢谢
如果不计较顺序,应有 2*2*2*2=16 种组合(简单一点)如果计较顺序,应有(2*2*2*2)*4!=384 种排列(麻烦一点).下面是计较顺序的排列。有点笨。因为不是N~M 组合通式,为解而解。虽啰嗦,但是好理解一点。仅供参考。
close ALL
set excl on
do pp
close all
use yy
brow
close all
return
**************************
procedure pp
create cursor aa (a c(1),b c(1))
insert into aa (a,b) value ('A','B')
insert into aa (a,b) value ('C','D')
insert into aa (a,b) value ('E','F')
insert into aa (a,b) value ('G','H')
create cursor dd (s1 c(1),s2 c(1),s3 c(1),s4 c(1),s5 c(1),s6 c(1),s7 c(1),s8 c(1),;
s9 c(1),s10 c(1),s11 c(1),s12 c(1),s13 c(1),s14 c(1),s15 c(1),s16 c(1))
create table yy (e c(4))
m=1
sele aa
go 3
nre=recno()
scatter to k
do while m<4
select * from aa into table bb where recno()<3 order by a
p1()
enddo
m=1
do while m<4
select * from aa into table bb where recno()<3 order by a desc
p1()
enddo
return
procedure p1
sele bb
if m<3
go m
insert blank before
gather from k
else
append blank
gather from k
endif
m=m+1
p2()
return
procedure p2
r=1
sele aa
go 4
scatter to j
do while r<5
select * from bb into table cc
sele cc
if r<4
go r
insert blank before
gather from j
else
append blank
gather from j
endif
r=r+1
p3()
enddo
return
procedure p3
sele cc
go 1
cs1=a
cs2=b
insert into dd (s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16);
value (cs1,cs2,cs2,cs1,cs1,cs2,cs2,cs1,cs1,cs2,cs2,cs1,cs1,cs2,cs2,cs1)
go 2
cs1=a
cs2=b
insert into dd (s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16);
value (cs1,cs1,cs2,cs2,cs1,cs1,cs2,cs2,cs1,cs1,cs2,cs2,cs1,cs1,cs2,cs2)
go 3
cs1=a
cs2=b
insert into dd (s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16);
value (cs1,cs1,cs1,cs1,cs2,cs2,cs2,cs2,cs1,cs1,cs1,cs1,cs2,cs2,cs2,cs2)
go 4
cs1=a
cs2=b
insert into dd (s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16);
value (cs1,cs1,cs1,cs1,cs1,cs1,cs1,cs1,cs2,cs2,cs2,cs2,cs2,cs2,cs2,cs2)
sele dd
w=1
do while w<17
go top
ssj=''
do while.not.eof()
ss='s'+alltrim(str(w))
ssj=ssj+&ss
skip
enddo
insert into yy (e) value (ssj)
w=w+1
enddo
sele dd
zap
return
[ 本帖最后由 qingfameng 于 2011-11-11 02:55 编辑 ]