当前位置:DOS资源站资料中心VBS脚本 → VBS算24点

VBS算24点

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2008-4-14 16:42:30

num=array("5","6","7","8")
fuhao=array("+","-","*","/")
dim all
for z=0 to 3
   for x=0 to 3
      for c=0 to 3
         for v=0 to 3
            if z<>x and z<>c and z<>v then
               if x<>c and x<>v then
                  if c<>v then
                     m num(z),num(x),num(c),num(v)
                  end if
               end if
            end if
         next
      next
   next
next
if all="" then
   msgbox "不能算到24点!"
else
   msgbox all
end if

function m(n1,n2,n3,n4)
for i=0 to 3
   for j=0 to 3
      for k=0 to 3
         r=yunsuan(n1,n2,fuhao(i))
         r=yunsuan(r,n3,fuhao(j))
         r=yunsuan(r,n4,fuhao(k))
         if r="24" then all=all+"(("+n1+fuhao(i)+n2+")"+fuhao(j)+n3+")"+fuhao(k)+n4+"="+r+chr(13)+chr(10)
      next
   next
next
end function

function yunsuan(s1,s2,ys)
   if instr(s1,"/")=0 then
      if ys="/" then
         yunsuan=s1+"/"+s2
      else
         yunsuan=cstr(eval(s1+ys+s2))
      end if
   else
      fj=split(s1,"/")
      bcs=fj(0)
      cs=fj(1)
      if ys="+" then yunsuan=cstr(eval(bcs+"+"+cs+"*"+s2))+"/"+cs
      if ys="-" then yunsuan=cstr(eval(bcs+"-"+cs+"*"+s2))+"/"+cs
      if ys="*" then yunsuan=cstr(eval(bcs+"*"+s2))+"/"+cs
      if ys="/" then yunsuan=bcs+"/"+cstr(eval(cs+"*"+s2))
   end if
end function
 

  • ·上一篇文章:vbs命令行参数
  • ·下一篇文章:Excel VBA工程密码破解程序
  • ·百度中搜索更多的关于“VBS算24点”相关内容
  • ·谷歌中搜索更多的关于“VBS算24点”相关内容
  • ******申明******
  • 本站文章内容有部分为收录网络中其他网友内容,DOS资源站不保证所有的代码都适合你使用。
  • 由于编辑匆忙,有可能造成某些脚本文件出现丢失代码或代码无法运行的情况,请网友根据情况自行修改。
  • 如果能将出错部分反馈给我,那就更好了。