一个for内解决问题,-
- @echo off&setlocal enabledelayedexpansion
- set "tab= "
- for /f "tokens=1* delims=:" %%a in ('findstr /o .* a.txt') do (
- if "%%b" equ "" (echo;) else (
- for /f "tokens=* delims= %tab% " %%c in ("%%b") do (set str=%%c)
-
- set/a a=8180,c=0&for /l %%a in (1,1,14) do (
- set/a "b=(a-c)/2+c"&for %%b in (!b!) do if "!str:~%%b,1!" equ "" (set/a a=b) else (set/a c=b)
- )&rem 此段字符长度计算用到 随风 的折半法
-
- set n=4
- set "ec= "
- for /l %%a in (0,1,!a!) do (set "one=!str:~%%a,1!"
- set ec=!ec!!one!
- if "!one!" geq "z" (set /a n+=2) else (set /a n+=1)
- if !n! geq 60 echo;!ec!&set ec=&set n=0
- )
- echo;!ec!
- )
- )
- pause
复制代码
[ 本帖最后由 netbenton 于 2009-8-12 22:58 编辑 ] |