数字1到9一共有9!种排法,要把这些排法都打印出来,除了用9次for语句,还能怎么求出来

来源:百度知道 编辑:UC知道 时间:2024/09/23 01:19:38
一楼的我看半天实在看不明白,不过还是谢了,我要的是C语言

递归也可以做到
<%
dim numarr,str
function p(tmp,str)
if len(str)=1 then
response.write tmp&str&vbcrlf
else
dim arr
if right(str,1)="," then str=left(str,len(str)-1)
arr=split(str,",")
for i=0 to ubound(arr)
p tmp&arr(i),replace(replace(str,Cstr(arr(i))&",",""),","&Cstr(arr(i)),"")
next
end if
end function
p "","1,2,3,4,5,6"

%>
以上为我用asp写的代码,供你参考
为防止超时,这里用1-6,6个数字进行测试