我把我的代码也贴到这,如果通用性有问题请告知
方法一:(用时0.25~0.30秒)- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (LastNumberChange.txt) do set/a n+=1&set LastLine=$%%i$
- for /f "delims=" %%i in (LastNumberChange.txt) do (
- set/a m+=1
- if %n% neq !m! call set "all=!all!%%i&echo."
- )
-
- :start
- set FirstNumber=%LastLine:~,1%
- set "all1=!all1!%FirstNumber%"
- set LastLine=%LastLine:~1%
- echo %LastLine%|findstr "[0-9]" >nul&&goto :start
- :all1
- set /a t+=1
- call set LastOne=%%all1:~-!t!%%
- set/a x=LastOne*1
- if "%LastOne%"=="%x%" goto :all1
- set/a LastOne=%LastOne:~1%*7
- set /a t-=1
- set xlm=!all1:~,-%t%!
- Set "Sum=%all%%xlm%%LastOne%%LastLine%"
- echo %Sum:$=%
- pause
复制代码 方法二:(用时0.02~0.05秒)- @echo off&setlocal enabledelayedexpansion
- for /f "delims=" %%i in (LastNumberChange.txt) do set/a n+=1&set LastLine=$%%i$
- for /f "delims=" %%i in (LastNumberChange.txt) do (
- set/a m+=1
- if %n% neq !m! call set "all=!all!%%i&echo."
- )
- :LastOne
- set/a x+=1
- call set LastOne=%%LastLine:~-!x!,1%%
- set /a Mult=%LastOne%*1
- if not "%Mult%"=="%LastOne%" goto :LastOne
- set/a x-=1
- call set Front=%%LastLine:~,-%x%%%
- call set Last=%%LastLine:~-%x%%%
- :Middle
- set/a x1+=1
- call set LastOne1=%%Front:~-!x1!%%
- set /a Mult1=%LastOne1%*1
- if "%Mult1%"=="%LastOne1%" goto :Middle
- set/a Middle=%LastOne1:~1%*7
- set/a x1-=1
- call set Front=%%Front:~,-%x1%%%
- set "Sum=%all%%Front%%Middle%%Last%"
- echo %Sum:$=%
- pause
复制代码
|