贴一个正统的解法
用到了临时文件
得亏事先造好了声势
可以不用偷偷摸摸了
楼主号称5句代码能够解题
等待瞻仰中……- @echo off & setlocal EnableDelayedExpansion
- rem 重置可能影响程序的环境变量为空
- for %%e in (lines context sizes cols) do set %%e=
-
- rem 将所有文本行拼成一行,并统计行数
- for /f "delims=" %%l in (a.txt) do set /a lines+=1&set "context=!context!%%l"
-
- rem 获取文本总字节数,并依此计算列数和列边界
- (echo %context%)>b.txt
- for %%f in (b.txt) do set /a sizes=%%~zf-2,cols=sizes/lines,collimit=cols-1
-
- rem 依照字符坐标转换,依次输出各列字符
- for /l %%i in (0,1,%collimit%) do (
- for /l %%j in (%%i,%cols%,%sizes%) do set/p=!context:~%%j,1!<nul
- echo.
- )
- pause
复制代码
|