- @echo off & setlocal enabledelayedexpansion
- set /a "w=80,h=35,t=w*h,xc=w/2,yc=h/2"
- mode %w%,40
- for /l %%i in (1 1 !t!) do set "s=!s! "
- call :f 0 -16 32 s
- echo;!s! &pause &exit
-
- :f xtop ytop hei s
- REM 半顶角对边与底角对边比: 1:1 , hei <= 1, 绘 3 点, 否则递归
- setlocal
- set "s=!%4!"
- if %3 leq 1 (
- set /a "a=%1 - 1, d=b=%2 + 1, c= %1 + 1"
- call :d %1 %2 & call :d !a! !b! & call :d !c! !d!
- ) else (
- set /a "h=%3 >> 1, a= %1 - h, d=b=%2 + h, c= %1 + h"
- call :f %1 %2 !h! %4 & call :f !a! !b! !h! %4 & call :f !c! !d! !h! %4
- )
- (
- endlocal
- set "%4=%s%"
- exit /b
- )
-
- :d
- set /a "i=%1-xc + (%2-yc) * w + 1, L=i-1"
- for /f "tokens=1,2" %%a in ("!L! !i!") do (set s=!s:~0,%%a!*!s:~%%b!)
- exit /b
复制代码
|