本帖最后由 neorobin 于 2012-6-2 11:26 编辑
将 半径 大于或等于 4 时, 调整为 高效算法- @echo off & setlocal enabledelayedexpansion
- if "%1"=="" (
- for %%a in ( FontSize:00080008
- FontFamily:00000030
- WindowSize:00c700c7
- ScreenColors:0000000f
- CodePage:000001b5
- ScreenBufferSize:00c700c7
- ) do for /f "tokens=1,2 delims=:" %%b in ("%%a") do (
- >nul reg add HKCU\Console\CharBox /v %%b /t reg_dword /d 0x%%c /f
- )
- start "CharBox" /max "%ComSpec%" /c "%~f0" 1&goto:eof
- ) else ( >nul reg delete HKCU\Console\CharBox /f )
-
-
- set "CS=zyx" & set "CSR=xyz"
- for /l %%p in (1 1 200) do set "_0=0!_0!"
- set "_1=!_0:0=x!"
- set "_2=!_0:0=y!"
- set "_3=!_0:0=z!"
- set NL=^
-
-
-
- for /l %%p in (1 1 99) do (
- title %%p
- set /a "rMax=%%p-1"
-
- if !rMax! lss 4 ( rem 同心圆算法, 效率太低, 故仅在半径小于 4 时处理
- for /l %%l in (-!rMax! 1 !rMax!) do (
- set "L="
- set /a "a=%%l, t=a>>31, a=(a+t)^t"
- for /l %%c in (-!rMax! 1 !rMax!) do (
- set /a "b=%%c, t=b>>31, b=(b+t)^t"
- set /a "t=(a-b)>>31, r=(t&b)|(~t&a), rd=r-rMax-1"
-
- if !r!==0 (
- if !rMax! geq 3 (set "L=!L!1") else set "L=!L!!CS:~-%%p,1!"
- ) else (
- if !rd! lss -3 (
- set "L=!L!0"
- ) else (
- for %%i in (!rd!) do set "L=!L!!CS:~%%i,1!"
- )
- )
- )
- echo,!L!
- )
- ) else ( rem 在半径不小于 4 时, 切换为高效率算法
-
- set "S3=" & set "E3="
- for %%i in (1 2 3) do (
- set /a "s=2*(rMax-%%i)+1"
- for %%s in (!s!) do (
- set "S3=!S3!!NL!!CSR:~0,%%i!!_%%i:~-%%s!!CS:~-%%i!"
- set "E3=!CSR:~0,%%i!!_%%i:~-%%s!!CS:~-%%i!!NL!!E3!"
- )
- )
-
- set /a "s=rMax-3"
- for %%s in (!s!) do set "LC=xyz!_0:~-%%s!1!_0:~-%%s!zyx"
- set "Ln=!LC:1=0!"
-
- echo,!S3:~1!
- for /l %%i in (1 1 !s!) do echo,!Ln!
- echo,!LC!
- for /l %%i in (1 1 !s!) do echo,!Ln!
- echo,!E3:~0,-1!
-
- )
- pause & cls
- )
复制代码
|