作业帮 > 综合 > 作业

0.1.2.3.4.5.6.7.8.9选出5个数排7成7位数 例如 12345 可排成1112345和1234511这种

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/09 10:54:08
0.1.2.3.4.5.6.7.8.9选出5个数排7成7位数 例如 12345 可排成1112345和1234511这种排列有多少种.用excel最
我想把 这些排列 详细的排列在 excel里面 .每种排列组合都要有的、.
按楼主要求,做脚本小工具.这个工具可以手工输入5个数,排出使用这5个数组成的全部7位数.
'WINDOWS下,将以下代码复制到记事本,保存后修改后缀名为“.VBS”.
'双击运行10秒钟直至弹出“完成”.
'结果文件保存在D盘下result_tools.txt.每5个数的结果文件大小均在295K左右.
'BY niminrenshi
on error resume next
rt =InputBox("请在对话框中输入0-9的5个不同数字." &vbCrlf & "数与数之间用半角空格隔开." & vbCrlf & "本次运算将会覆盖上次运算的结果文件,请注意保存.","5个数排成7位数小工具","0 1 2 3 4")
rt =Trim(rt)
if rt = vbCancel or rt = "" then
Wscript.Quit
End if
rt =Split (rt," ")
set fso = CreateObject ("SCripting.FileSystemObject")
set hw = fso.CreateTextFile ("D:\result_tools.txt",true,-2)
set wshshell = CreateObject("WScript.Shell")
dim shuzu (8)
for i1 = 0 to 4
for i2 = 0 to 4
for i3 = 0 to 4
for i4 = 0 to 4
for i5 = 0 to 4
for i6 = 0 to 4
for i7 = 0 to 4
nnum = i1 & i2 & i3 & i4 & i5 & i6 & i7
shuzu(1) = i1
shuzu(2) = i2
shuzu(3) = i3
shuzu(4) = i4
shuzu(5) = i5
shuzu(6) = i6
shuzu(7) = i7
for m = 1 to 6
for n = m +1 to 7
if shuzu(m) > shuzu (n) then
t = shuzu(m)
shuzu(m) = shuzu(n)
shuzu(n) = t
end if
next
next
numgs = 0
for m = 2 to 7
if shuzu(m) = shuzu(m-1) then
numgs = numgs + 1
end if
next
if numgs = 2 then
hw.WriteLine nnum
end if
next
next
next
next
next
next
next
hw.Close
MsgBox "完成"
Wscript.Quit
'代码结束