Thanks to so many experts, it's perfect!
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
@echo off&setlocal enabledelayedexpansion
set/p str=Please enter characters:
:lp
if defined str (
set num=!str:~,1!
if not defined ..!num! (
set /a n+=1
set ..!num!=b
set "_!n!=!str:~,1!"&set "str=!str:~1!"
goto lp
) else (
set "str=!str:~1!"
goto lp
))
call:next
echo %mn% combinations
pause&exit
:next
set/a m+=1
if %m% leq %n% for /l %%i in (1 1 %n%) do (
for %%j in (%~1) do set .%%j=%%j
if not defined .%%i call :next "%~1 %%i"
for /l %%k in (1 1 %n%) do set .%%k=
) else (
for /l %%l in (1 1 %n%) do set .%%l=
for %%m in (%~1) do set/p=!_%%m!<nul
echo.
set/a mn+=1
)
set/a m-=1
@echo off&setlocal enabledelayedexpansion
set/p str=Please enter characters:
:lp
set num=!str:~,1!
if not defined .!num! (
set str1=!str1!!num!
set /a n+=1
set .!num!=b
set "_!n!=!str:~,1!"&set "str=!str:~1!"
if defined str goto lp
)else (
set "str=!str:~1!"
if defined str goto lp
)
set/a n-=1
>b.bat echo @echo off^&setlocal enabledelayedexpansion
>>b.bat echo set "str=%str1%"
>>b.bat echo for /l %%%%i in (0 1 %n%) do set _%%%%i=^^!str:~%%%%i,1^^!^&set var0=^^!var0^^! %%%%i
for /l %%i in (0 1 %n%) do (
set/a m+=1
if !m! gtr %n% (
>>b.bat echo for %%%%%%i in (^^!var%%i^^!^) do echo !var!^^!_%%%%%%i^^!)else (
>>b.bat echo for %%%%%%i in (^^!var%%i^^!^) do ^(set "var!m!=^!var%%i:%%%%%%i=^!"
set "var=!var!^!_%%%%%%i^!"
set "k=!k!^)"
))
>>b.bat echo set/a t+=1
>>b.bat echo %k%
>>b.bat echo echo %%t%% combinations
call "b.bat"
del "b.bat"
pause>nul
Originally posted by clian76 at 2008-12-23 13:49:
Tested the code above, but it didn't meet the desired requirement. The code above only tells how many combinations there are. But it doesn't exclude the existing duplicate combinations.
My method is to generate a...