稍作修改即可 输出 到文件, 将原来的关键输出代码 全部 括起, 如下重新安排复制代码 做好后便是- @echo off
- setlocal enableDelayedExpansion
- >ip2.txt (
- for /f "delims=" %%l in (ip.txt) do (
- set "cnt=0"
- for %%i in (%%l) do (
- set /a cnt+=1
- if !cnt! leq 2 (
- set tt=%%i
- REM set /a (((222)*256+248)*256+240)*256+1 这种形式的结果将超出批处理计算范围, 故不可用
- set "sum=0"
- for %%t in (!tt:.^= !) do (
- call :cen !sum! 256 sum
- call :jia !sum! %%t sum
- )
- set /p=!sum! <nul
- ) else set /p= %%i<nul
- )
- echo.
- )
- )
- start ip2.txt
- pause
- exit /b
-
- :jia 加法函数(封装)by @随风 @bbs.bathome.net
- ::计算任意位数的正整数加法
- setlocal enabledelayedexpansion&set f=&set "t="
- set var1=%~1&set var2=%~2&set /a j=0,n1=0,n2=0
- for /l %%a in (0 1 9) do (set vard1=&set "vard2="
- set var1=!var1:%%a= %%a !&set var2=!var2:%%a= %%a !)
- for %%a in (!var1!)do (set/a n1+=1&set vard1=%%a !vard1!)
- for %%a in (!var2!)do (set/a n2+=1&set vard2=%%a !vard2!)
- (if !n1! lss !n2! (set var1=%var2%&set "var2=%var1%"
- set vard1=%vard2%&set vard2=%vard1%))&set "var2=!var2: =!"
- for %%a in (!vard1!) do (if "!var2!"=="" set /a var2=0
- set /a a=%%a+!var2:~-1!+j&set t=!a:~-1!!t!&set "a=0!a!"
- set "j=!a:~-2,1!"&set var2=!var2:~0,-1!)
- if !j! neq 0 set "t=!j!!t!"
- Endlocal&set %~3=%t%&goto :EOF
-
- :cen 乘法函数(封装)by @随风 @bbs.bathome.net
- ::计算任意位数的正整数乘法
- setlocal enabledelayedexpansion
- if "%~1"=="0" Endlocal&set %~3=0&goto :EOF
- if "%~2"=="0" Endlocal&set %~3=0&goto :EOF
- set f=&set jia=&set ji=&set /a n1=0,n2=0
- set vard1=&set "vard2="&set var1=%~1&set "var2=%~2"
- for /l %%a in (0 1 9) do (
- set var1=!var1:%%a= %%a !&set var2=!var2:%%a= %%a !)
- for %%a in (!var1!)do (set /a n1+=1&set vard1=%%a !vard1!)
- for %%a in (!var2!)do (set /a n2+=1&set vard2=%%a !vard2!)
- if !n1! gtr !n2! (set vard1=%vard2%&set vard2=%vard1%)
- for %%a in (!vard1!) do (set "t="&set /a j=0
- for %%b in (!vard2!) do (if "!jia!"=="" set /a jia=0
- set /a a=%%a*%%b+j+!jia:~-1!&set "t=!a:~-1!!t!"
- set a=0!a!&set "j=!a:~-2,1!"&set jia=!jia:~0,-1!)
- set "ji=!t:~-1!!ji!"
- if "!j:~0,1!"=="0" (set ss=) else set "ss=!j:~0,1!"
- set jia=!ss!!t:~0,-1!)
- if not "!j:~0,1!"=="0" set "t=!j:~0,1!!t!"
- set "ji=!t!!ji:~1!"
- Endlocal&set %~3=%ji%&goto :EOF
复制代码
|