本帖最后由 terse 于 2013-6-8 14:10 编辑
有点给数字绕晕的感觉
只能再试着简化下 思路闭塞 总不能突破- @echo off&setlocal enabledelayedexpansion
- %1 %0 :|more /t32 >n.txt&exit
- set "file=test.txt"
- for /f "delims=U" %%a in ('cmd /u /c echo 唉') do set "tab=%%a"
- for /f "usebackq tokens=*" %%i in ("%file%") do set /a N+=1&set #!N!=%%i
- set L=9
- set /a "h=(n+l-1)/l,i=^!(~-l/h),j=^!i*(n%%l)*h+i*n"
- for /l %%i in (1 1 !n!) do (
- set /a "i=^!(~-%%i/j),m=(~-%%i-(^!i*j))%%(~-h+i)+1"
- for %%j in (!m!) do set "$%%j=!$%%j!%tab%!#%%i!"
- )
- for /l %%i in (1 1 !h!) do for /f "tokens=*" %%j in ("!$%%i!") do echo %%j
复制代码 既然MORE 最后回车肯定有 没必要再处理它了吧- @echo off&setlocal enabledelayedexpansion
- %1 %0 :|more /t32 >n.txt&exit
- set "file=test.txt"
- for /f "delims=U" %%a in ('cmd /u /c echo 唉') do set "tab=%%a"
- for /f "usebackq tokens=*" %%i in ("%file%") do set /a N+=1&set #!N!=%%i
- set L=9
- set /a "h=(n+l-1)/l,j=n%%l,i=^!(l/h)"
- if !j! equ 0 (set j=!n!)else set /a "j=~-l*h*i+j*h"
- for /l %%i in (1 1 !n!) do (
- set /a "i=^!(~-%%i/j),m=(~-%%i-(^!i*j))%%(~-h+i)+1"
- for %%j in (!m!) do set "$%%j=!$%%j!%tab%!#%%i!"
- )
- for /l %%i in (1 1 !h!) do for /f "tokens=*" %%j in ("!$%%i!") do echo %%j
复制代码
|