悬崖之树 当前离线
上尉
@echo off setlocal enabledelayedexpansion set m=0&set $11=1 :loop set /a m+=1 for /l %%i in (1 1 %m%) do ( set /a a=%m%-1 set /a b=%%i-1 for %%a in (!a!) do ( for %%b in (!b!) do ( set /a $%m%%%i=!$%%a%%b!+!$%%a%%i! set /p =!$%m%%%i! <nul ) ) ) echo.&goto loop复制代码
CrLf 当前离线
论坛巡查
TOP
@echo off setlocal enabledelayedexpansion set /a m=0,$00=1 :loop set /a m+=1 for /l %%i in (1 1 %m%) do ( set /a a=%m%-1,b=%%i-1 set /a $%m%%%i=$!a!!b!+$!a!%%i set /p =!$%m%%%i! <nul ) set /a $%m%1=$%m%%m%=1 echo.&goto loop复制代码
首先是用 for /l 代替 goto :loop 来大幅加速 其次,set /p 是比较耗时的,可以把要输出的行合并到一个变量中再 echo 除此,还可以在set /p 之前加一句 set "$!a!!b!=" 清空已经用不着的变量,避免在层数大的时候多余的变量影响读写变量表的效率复制代码
terse 当前离线
中将
@echo off&setlocal enabledelayedexpansion set line=15 for /l %%i in (1 1 %line%) do ( for /l %%j in (%%i -1 2) do ( set /a N=%%j-1 set /a $%%j+=$!N! ) set $%%i=1 for /l %%j in (1 1 %%i) do set /p=!$%%j! <nul echo. ) pause复制代码
@echo off setlocal enabledelayedexpansion set /a a=0,$00=1,end=15 for /l %%a in (1 1 %end%) do ( set /a b=echo=1 for /l %%i in (2 1 %%a) do ( set /a $%%a%%i=$!a!!b!+$!a!%%i,b=%%i set "echo=!echo! !$%%a%%i!" ) echo;!echo! set /a $%%a1=$%%a%%a=1,a=%%a ) pause复制代码
523066680 (消遣区)当前离线
版主
评分人数
@echo off setlocal enabledelayedexpansion set /a lv=0,maxlv=10 call :Tri pause &exit :Tri set /a ever=0,lv+=1 set str= for %%a in (%*) do ( set /a next=ever+%%a,ever=%%a set "str=!str!!next! " ) echo !str!1 if %lv% lss %maxlv% ( call :Tri !str!1 )复制代码
@echo off setlocal enabledelayedexpansion set str= for /l %%m in (1,1,10) do ( set /a ever=0 set ts= for %%a in (!str!) do ( set /a next=ever+%%a,ever=%%a set "ts=!ts!!next! " ) echo "!ts!1" set str=!ts!1 ) pause复制代码
@echo off setlocal enabledelayedexpansion set /a m=0,$01=1 for /l %%j in (1 1 10) do ( set /a m+=1 for /l %%i in (1 1 !m!) do ( set /a a=!m!-1,b=%%i-1 set /a $!m!%%i=$!a!!b!+$!a!%%i call set /p =%%$!m!%%i%% <nul ) echo. ) pause复制代码
set /a var*1复制代码
set /a !var!*1复制代码
set /a %var%*1复制代码
set /a 出错的算式复制代码
echo set /a 出错的算式 set /a 出错的算式 pause复制代码