本帖最后由 a20150604 于 2019-9-1 14:12 编辑
回复 1# Batcher - ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- ::
- :: problem: http://www.bathome.net/thread-53773-1-1.html
- :: 问题:
- :: 几行混成一行,第一行是1234567第二行是891011121314第三行是151617181920第四行是21222324252627
- :: 第五行是28293031323334第六行是353637383940就是说每3行是776这样排,有听懂的帮我做一下
- ::
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
- @echo off
- setlocal enabledelayedexpansion
- set "RULE=7 7 6"
- set "FileOld=1.txt"
- set "FileNew=2.txt"
-
- REM make FileOld
- >%FileOld% ( for /L %%i in (1 1 100) do (echo;%%i) )
-
- set /a "cycle=%RULE: =+%"
-
- set /a "sum=0,cnt=1"
- for %%a in (%RULE%) do (
- set /a "p_!cnt!=(sum+=%%a)-1,cnt+=1"
- )
-
- set /a cnt-=1
- set "_test="
- for /L %%i in (1 1 %cnt%) do (
- REM debug info
- REM echo;%%i;!p_%%i!
- set "_test=!_test!NOT(#-!p_%%i!)^|"
- )
- set "_test="(!_test:~0,-1!)""
-
- setlocal DISABLEDELAYEDEXPANSION
- set "_test="test=%_test:NOT=!%""
- REM debug info
- REM set _test
-
- setlocal enabledelayedexpansion
-
- >%FileNew% cd.
- set "output_line="
- set /a "line_ind=-1" & rem 首行记为 第 0 行
-
- >%FileNew% (
- for /f "delims=" %%a in (%FileOld%) do (
- set "output_line=!output_line!%%a"
-
- set /a "line_ind_in_cycle=(line_ind+=1) %% cycle, !_test:#=line_ind_in_cycle!"
- REM debug info
- REM echo;%%a;!line_ind_in_cycle!;!test!
- if !test!==1 (
- echo;!output_line!
- set "output_line="
- )
- )
- )
- start "" "%FileNew%"
- <nul set /p=Press any key to exit...
- >nul pause
复制代码
|