本帖最后由 老刘1号 于 2017-7-2 18:02 编辑
回复 1# bbaa
回复 18# codegay
回复 15# happy886rr
取平均数递归法,最多计算6次就可得出结果
欢迎测试~(存Bat)- '&cls&@echo off&cscript -nologo -e:vbscript "%~0"&pause&exit
- With CreateObject("MSXML2.XMLHTTP")
- .Open "POST", "http://bbaass.tk/math/", False
- .setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
- .Send "send=reg&username=老刘"
- End With
-
- Do
- Bisection -1,101,0
- Loop
-
- Sub Bisection(low,high,s)
- Mid_=(High+Low)\2
- if s<=7 then
- Select Case Cstr(Math(Mid_))
- Case "="
- wscript.echo "Win!The number is "&Mid_
- Case ">"
- WScript.Echo ">,so try "&Low&","&Mid_
- Bisection Low,Mid_,s+1
- Case "<"
- WScript.Echo "<,so try "&Mid_&","&High
- Bisection Mid_,High,s+1
- End Select
- end if
- End Sub
-
- Function Math(num)
- With CreateObject("MSXML2.XMLHTTP")
- .Open "POST","http://bbaass.tk/math/", False
- .setRequestHeader "CONTENT-TYPE","application/x-www-form-urlencoded"
- .send "send=Answer&math=" & num & "&username=老刘"
- Math = Split(Split(.responseText,",")(2),"""")(3)
- End With
- End Function
复制代码
|