批处理杨辉三角效果实现代码
发布时间:2016-12-04 19:30:29 所属栏目:教程 来源:网络整理
导读:效果图: 复制代码 代码如下: @echo offcolor 0e setlocal enabledelayedexpansion mode con: cols=130 lines=130 :top cls ::set /p in=请输入行数: set in=23set ab=1set var=64 if "%in%"=="" goto top if %in% geq 35 goto top if %in% leq 0 goto top
效果图:![]() 复制代码 代码如下: @echo offcolor 0e setlocal enabledelayedexpansion mode con: cols=130 lines=130 :top cls ::set /p in=请输入行数: set in=23set ab=1set var=64 if "%in%"=="" goto top if %in% geq 35 goto top if %in% leq 0 goto top echo %in%|findstr /r "^[0-9][0-9]*$"gt;nul 2gt;nul||goto top set str=1 for /l %%i in (1,1,%in%) do ( nbsp;nbsp; set num= nbsp;nbsp; set num2=0 nbsp;nbsp; for %%a in (!str!) do ( nbsp;nbsp; set /a num2+=1 nbsp;nbsp; if !num2!==1 set "str1=" nbsp;nbsp; set /a num1=%%a+num nbsp;nbsp; set "str1=!str1! !num1!" nbsp;nbsp; set num=%%a nbsp;nbsp; ) nbsp;nbsp; call :lis "!str1:~1!" nbsp;nbsp; set "str=!str1! 0" ) rem 再输出个倒 金字塔 玩玩。 for /l %%a in (22 -1 1) do echo !nam%%a! for /l %%i in (1 1 3) do ( nbsp; for %%a in (a b c d e f) do ( nbsp; color 0%%a nbsp; ping/n 2 127.1gt;nul nbsp; )) exit :lis set max=%~1 for /l %%a in (0 1 300) do ( if not "!max:~%%a,1!"=="" set /a ci+=1 ) set /a ki=var-ci/2 for /l %%a in (1 1 !ki!) do set kg= !kg! echo !kg!!max! set nam!ab!=!kg!!max! set /a ab+=1 set ci=0set kg= goto :eof (编辑:应用网_丽江站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |