如果字符数多且组合字数多,不知道呈什么级数增长(我数学不太好)。最多处理15个字符:- @echo off
- setlocal enableDelayedExpansion
- set arr=bathome
- set num=5
- set /p num=需要组合的字数:
- set var=%arr%fedcba9876543210
- set /a len=0x%var:~15,1%
- set /a numx=num-1, lenx=len-1
- for /l %%a in (0 1 %numx%) do (
- if 0==%%a (set start=0) else (set /a start=%%a-1&set start=%%!start!)
- set "do=!do! for /l %%%%a in (!start!,1,%lenx%) do "
- set "exp=!exp!^!arr:~%%%%a,1^!"
- )
- %do% echo %exp%
- pause
- endlocal
复制代码
|