根据3楼思路改写,实现列与列之间空格最少:- @echo off
- setlocal enabledelayedexpansion
- set n=0
- for /f "tokens=1,2" %%i in (1.txt) do (
- set "var=%%i%%j"
- set m=0
- call :1
- )
- for /l %%x in (1,1,!n!) do set KG= !KG!
- set /a n+=1
- for /f "tokens=1-3" %%a in (1.txt) do (
- set str=%%a%%b%KG%
- for %%y in (!n!) do set str=!str:~0,%%y!
- set str=!str:%%b=!%%b %%c
- echo !str!
- )
- pause
- goto :eof
- :1
- if not "!var:~%m%,1!"=="" set /a m+=1&goto 1
- if %m% gtr %n% set n=%m%
- goto :eof
复制代码
|