贴一个问题1的解决方案(非gawk)- @echo off
- setlocal enabledelayedexpansion
-
- rem 定义所有四元组组合
- set combinations=1234 1235 1236 1237 1245 1246 1247 1256 1257 1267 1345 1346 1347 1356 1357 1367 1456 1457 1467 1567 2345 2346 2347 2356 2357 2367 2456 2457 2467 2567 3456 3457 3467 3567 4567
-
- rem 清空现有输出文件
- for %%C in (%combinations%) do if exist %%C.txt del %%C.txt
-
- rem 逐行处理A.txt
- for /f "usebackq delims=" %%L in ("A.txt") do (
- set "line=%%L"
- for %%C in (%combinations%) do (
- set "pos=%%C"
- rem 提取四个位置索引
- set /a i1=!pos:~0,1!-1
- set /a i2=!pos:~1,1!-1
- set /a i3=!pos:~2,1!-1
- set /a i4=!pos:~3,1!-1
- rem 截取字符并拼接
- for %%a in (!i1!) do set "c1=!line:~%%a,1!"
- for %%a in (!i2!) do set "c2=!line:~%%a,1!"
- for %%a in (!i3!) do set "c3=!line:~%%a,1!"
- for %%a in (!i4!) do set "c4=!line:~%%a,1!"
- echo !c1!!c2!!c3!!c4!>>%%C.txt
- )
- )
-
- endlocal
复制代码
|