@echo %dbg% off&setlocal enabledelayedexpansion
for /L %%I in (2147483647, -33554428, 0) do (
call :errMake %%I
call :errFind >NUL
echo !errFind!.
if "!errFind!" neq "%%I" echo OOPS.& exit /b
)
echo All Done.&pause
goto:eof
:errMake
exit /b %~1
:ErrFind
(
if not defined Result set Result=%0&set Result=!Result:~1!&(
if not errorlevel 1 set !Result!=0&set Result=&goto:eof
)&set H=2147483647&(
if errorlevel !H! set !Result!=!H!&set H=&set Result=&goto:eof
)&set L=0
)&set/a A=H/2+L/2&echo H:!H! A:!A! L:!L!&(
if errorlevel !A! (
(
if !L!==!A! set H=&set/a A+=1&(
if not errorlevel !A! set A=!L!
)&set L=&set !Result!=!A!&set A=&set Result=&goto:eof
)&set L=!A!
)else set H=!A!
)&goto %0
此段代码不是一般的值得学习研究,
有别于本论坛中其他所有代码的,这是代码处理问题方式的一个另类.
看上去好象只是65次循环,其实它的计算次数几乎是爆炸模式递增的,
太不可思议了.我现在在想,本段代码是否是利用了batch的某个特性??
这让我想起了下面这段代码.
type %~dpnx0>>%~dpnx0&%0
啊!我好象有点明白了.......它的计算次数不是几何递增模式的...
我再考虑考虑.......
-------------------------------
FT!就是65次!!我被骗了!
---------------------------------
ECHO %DBG% OFF
FOR /L %%I IN (2147483647,-33554428,0) DO ECHO %%I
.
Last edited by qjbm on 2007-2-19 at 11:48 PM ]