一个排列问题:
给定集合 {a,b,c},其全排列为:
abc
acb
bac
bca
cab
cba
如何写一个程序,打印一个给定集合,如:
{1,2,3,4,5,6,7}
的全排列?
程序作者:y0h
<%
dim max,str1
dim sarray
str1=","
sarray=split("a,b,c,d,e,f,g,h",",")
max=ubound(sarray)
test max,max,str1
function test(max,x,str1)
if x>=0 then
for i=0 to max
if instr(str1,","&sarray(i)&",")=0 then
test max,x-1,str1&sarray(i)&","
end if
next
else
response.write(str1&"<br>")
end if
end function
%>