『第
47 楼』:
附一个很早以前写的批处理
@ECHO OFF
set dataA=0 128 192 224 240 248 252 254 255
set ier=输入错误! key:
set con=999
if not "%1" == "" (set con=1&&set go=des) else goto int
if not "%1" == "" echo %1|find ".">nul&&set go=int
goto %go%
:int
cls
if %con% equ 1 (set mask=%1&&set con=0) else set /p mask=MASK:
:chk1
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "tokens=1-4 delims=." %%a in ("%mask%") do if %%a lss 128 (cls&echo %mask% %ier%1 %%a^>128&goto int) else set m_1=%%a&set m_2=%%b&set m_3=%%c&set m_4=%%d
for /f "tokens=2,3 delims==_" %%i in ('set m_') do echo %%j|findstr /v /b /e "%dataA%"&&cls&&echo %mask% %ier%2&&echo 第%%i段 %%j&&goto int
set /a _tmp1=%m_1%+%m_2%+%m_3%+%m_4%
set /a _tmp2=4
:chk2
set /a _tmp3=!m_%_tmp2%!
if not "%_tmp3%" == "0" (echo.) else set /a _tmp2=%_tmp2%-1&&goto chk2
set /a _tmp4=%_tmp1%-%_tmp3%
set /a _tmp5=%dataA:~-3%*(%_tmp2%-1)
if %_tmp4% == %_tmp5% (goto next) else echo %mask% %ier%3&goto int
:next
set /a des1=%_tmp2%*8-8
if "%_tmp3%" == "%dataA:~2,3%" set des2=1
if "%_tmp3%" == "%dataA:~6,3%" set des2=2
if "%_tmp3%" == "%dataA:~10,3%" set des2=3
if "%_tmp3%" == "%dataA:~14,3%" set des2=4
if "%_tmp3%" == "%dataA:~18,3%" set des2=5
if "%_tmp3%" == "%dataA:~22,3%" set des2=6
if "%_tmp3%" == "%dataA:~26,3%" set des2=7
if "%_tmp3%" == "%dataA:~30,3%" set des2=8
set /a des=%des1%+%des2%
echo MASK:%mask%=%des%
ENDLOCAL
goto end
:des
cls
if "%1" == "mask" set con=0
if %con% equ 1 (set mask=%1&&set con=0) else set /p mask=MASK:
:ce
echo %mask%|find "- ."&&cls&&echo %mask% %ier%1&&goto des
set /a mask1=%mask%/8
set /a mask2=%mask%%%8
set /a chk=%mask1%+%mask2%
if %chk% gtr 0 (if %chk% gtr 4 (cls&&echo %mask% %ier%2&&goto des)) else cls&&echo %mask% %ier%3&&goto des
set s1=0&set s2=0&set s3=0&set s4=0&set s5=%mask1%
if "%mask1%" == "0" (set s0=%mask%&&goto ct) else set s0=%mask2%
:cf
set s%s5%=255
set /a s5=%s5%-1
if not "%s5%" == "0" goto cf
:ct
if "%s0%" == "0" set s=%dataA:~0,1%
if "%s0%" == "1" set s=%dataA:~2,3%
if "%s0%" == "2" set s=%dataA:~6,3%
if "%s0%" == "3" set s=%dataA:~10,3%
if "%s0%" == "4" set s=%dataA:~14,3%
if "%s0%" == "5" set s=%dataA:~18,3%
if "%s0%" == "6" set s=%dataA:~22,3%
if "%s0%" == "7" set s=%dataA:~26,3%
if "%s0%" == "8" set s=%dataA:~30,3%
set /a _tmp=%mask1%+1
set s%_tmp%=%s%
echo %mask%=%s1%.%s2%.%s3%.%s4%
:end
pause>nul
exit
|