有一组数据:[01,02,04,08,09,12,13,14,15,19,20,22,23,25,28,30,31,34,35]
每5个数字一行,
中间用逗号隔开,
每行数据不同,
还要排序
用XP批处理代码编写>>a.txt
格式如下:
01,02,04,08,09
01,02,04,08,12
01,02,04,08,13
......
01,02,04,08,35
01,02,04,09,12
01,02,04,09,13
.......
var[01,02,04,08,09,12,13,14,15,19,20,22,23,25,28,30,31,34,35]
参照@terse写的代码
________________________________________________- @echo off&setlocal enabledelayedexpansion
- set " var=01 02 03 04 05 06 07 08 09 10"
- set "m=5"
- for %%i in (%var%) do (
- set /a n+=1&set #!n!=%%i
- if !n! leq !m! (set s=1!s!)else set s=!s!0
- )
- set/a r=n-m,i=j=1
- for /l %%i in (1,1,%r%) do set /a "i*=(n-%%i+1),j*=%%i"
- set s=0!s!&set /a "i/=j"
- (for /l %%i in (1 1 !i!) do (
- for /l %%j in (1 1 !n!) do (
- if "!s:~%%j,1!" == "1" set $=!$!,!#%%j!
- )
- for /f %%a in ("!s:10= !") do set "j=%%a"
- set s=0!j:0=!!j:1=!1!s:*10=!
- echo!$!&set "$="
- ))>$#.t
- sort $#.t /o a.txt
- del $#.t
- pause
复制代码 ________________________________________________
排列组合公式:
set /a "i*=(n-%%i+1),j*=%%i"
C [10,5] =10*9*8*7*6/(5*4*3*2*1)=252
set /a "i/=j"
i=i(30240)/j(120)
i=252 |