呵呵,大家都用猜的~,把CrLf代码改改成这样。- @echo off&setlocal enabledelayedexpansion
-
- rem 生成测试文件
- (for /l %%a in (1,1,26) do echo %%a)>$1
-
- rem 以下主体部分
- for /f "delims=U" %%a in ('cmd /u /c echo 唉') do set "tab=%%a"
- (for /f "delims=" %%a in ($1) do set /a n+=1&set /p ar[!n!]=)<$1
- set /a 列数=5,列宽=5,m=n/列数,余数=n%%列数,行数=(n+列数-1)/列数,修正递增=行数-1,修正终值=行数*余数
-
- if !修正终值! neq 0 (
- set 有余数=.
- if %列数% leq %m% set /a 修正终值="(列数-1)*行数"
- call :sc "!修正终值!"
- ) else (
- call :sc "!n!"
- )
- more /t%列宽% $t>b.txt
- del $?&start b.txt&exit /b
-
- :sc
- set /a a=c=行数,b=0,d=%~1
- :loop
- for /l %%a in (1 1 %a%) do (
- set /a b+=1
- for /l %%b in (!b! %c% %d%) do (
- if "!str%%a!"=="" (
- set "str%%a=!ar[%%b]!"
- ) else (
- set "str%%a=!str%%a!%tab%!ar[%%b]!"
- )
- )
- )
- if defined 有余数 (
- set /a a=行数-1,b=修正终值,c=修正递增,d=n
- set "有余数="
- goto :loop
- )
- (
- echo 当文档总行数=%n%,列数c=%列数%,每列行数x=%m%,余数=%余数%时
- if !列数! leq !m! (echo 即c小于等于x) else echo 即c大于x
- for /l %%a in (1,1,%行数%) do echo,!str%%a!
- )>$t
- goto :eof
复制代码
|