- @echo off
- for /f "delims=" %%a in ('sort /+4096 a.txt') do (
- set line=%%a
- set $=%%a#
- set len=-1
- setlocal enabledelayedexpansion
- for %%a in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1)do (
- if !$:~%%a^,1!. NEQ . set/a len+=%%a&set $=!$:~%%a!
- )
- rem 二分回溯法判断字符串长度,为避免 call 降低效率,将函数内置
- set "str="
- for /l %%a in (!len! -1 0) do set str=!str!!line:~%%a,1!
- echo !str!
- rem 字符串倒序
- endlocal
- )
- pause
复制代码
|