@echo off
if "%1" == "" goto help
set n=%1
set from=1
set to=3
set using=2
if "%2" == "" goto label1
set from=%2
set to=%3
set using=%4
:label1
if "%n%" == "0" goto exit
set n_1=0
if "%n%" == "1" goto label2
set n_1=1
if "%n%" == "2" goto label2
set n_1=2
if "%n%" == "3" goto label2
set n_1=3
if "%n%" == "4" goto label2
set n_1=4
if "%n%" == "5" goto label2
set n_1=5
if "%n%" == "6" goto label2
set n_1=6
if "%n%" == "7" goto label2
set n_1=7
:label2
%comspec% /c "hanoi.bat %n_1% %from% %using% %to%"
echo move %from% - %to%
%comspec% /c "hanoi.bat %n_1% %using% %to% %from%"
goto exit
:help
echo usage: hanoi N
:exit
BATでご~! (スコア:1)
Nは8までしか対応してませんけど(^^;)
一応、再帰使ってます~。
hanoi.bat:
@echo off
if "%1" == "" goto help
set n=%1
set from=1
set to=3
set using=2
if "%2" == "" goto label1
set from=%2
set to=%3
set using=%4
:label1
if "%n%" == "0" goto exit
set n_1=0
if "%n%" == "1" goto label2
set n_1=1
if "%n%" == "2" goto label2
set n_1=2
if "%n%" == "3" goto label2
set n_1=3
if "%n%" == "4" goto label2
set n_1=4
if "%n%" == "5" goto label2
set n_1=5
if "%n%" == "6" goto label2
set n_1=6
if "%n%" == "7" goto label2
set n_1=7
:label2
%comspec% /c "hanoi.bat %n_1% %from% %using% %to%"
echo move %from% - %to%
%comspec% /c "hanoi.bat %n_1% %using% %to% %from%"
goto exit
:help
echo usage: hanoi N
:exit