给5个人分10个苹果(每人至少分到一个苹果)
[ Last edited by jmz573515 on 2007-2-1 at 02:27 PM ]
aa=0
do until aa=1
i=inputbox("你想给5人分几个苹果?(每人至少一个)","请输入苹果数")
if i="" then
wscript.quit
elseif IsNumeric(i)=false then
msgbox "输入错误,请重新输入!",16+4096,"错误"
elseif i<5 then
msgbox "苹果数不能小于5,请重新输入!",16+4096,"错误"
elseif i>15 then
yesno=msgbox("苹果数大于15时速度可能会很慢,要继续吗?",32+4096+vbyesno,"提示")
if yesno=vbyes then
aa=1
end if
else
aa=1
end if
loop
set fso=createobject("scripting.filesystemobject")
set ws=createobject("wscript.shell")
set file=fso.createtextfile("OUT.txt",2)
for a=1 to ccur(i)-4
for b=1 to ccur(i)-4
for c=1 to ccur(i)-4
for d=1 to ccur(i)-4
for e=1 to ccur(i)-4
if a+b+c+d+e=ccur(i) then
h=h+1
s=s & "│" & a & vbtab & "│" & b & vbtab & "│" & c & vbtab & "│" & d & vbtab & "│" & e &vbtab &"│" &vbcrlf & "├───┼───┼───┼───┼───┤"&vbcrlf
end if
next
next
next
next
next
s=Left(s,Len(s)-Len("├───┼───┼───┼───┼───┤"&vbcrlf))
file.write "给5个人分"&i&"个苹果(每人至少分到一个苹果)一共有" & h &"种方法" & vbcrlf & vbcrlf
file.write "┌───┬───┬───┬───┬───┐"& VBcrlf
file.write "│A" & vbtab &"│B" & vbtab &"│C" & vbtab &"│D" & vbtab &"│E" & vbtab &"│" & VBcrlf
file.write "┝━━━┿━━━┿━━━┿━━━┿━━━┥"& VBcrlf
file.write s
file.write "└───┴───┴───┴───┴───┘"
file.close
ws.run "notepad.exe OUT.txt"
[ Last edited by jmz573515 on 2007-2-1 at 02:27 PM ]

