发帖时就勾股定理还是股沟定理的问题纠结了半天,天呐,数学老师我对不起您...
基本代码如下:- @echo off & setlocal EnableDelayedExpansion
- set /a n=20
- for /l %%a in (-%n% 2 %n%) do (
- for /l %%b in (-%n% 1 %n%) do (
- set /a r2=%%a*%%a+%%b*%%b-n*n
- if !r2! gtr 0 (set /p=@) else set /p=_
- )
- echo;
- )<nul
- pause>nul
复制代码 以下没什么技术含量,纯凑字数显得帖子比较丰满。
稍稍改动画个空心圆:- @echo off & setlocal EnableDelayedExpansion
- set /a n=20,m=0,nn=n+1
- for /l %%a in (-%n% 2 %n%) do (
- setlocal
- for /l %%b in (-%n% 1 %nn%) do (
- set /a "m=(%%a*%%a+%%b*%%b-n*n-1)>>31",test=!m!-m
- if !test!==1 (set r=!r!@) else (
- if !test!==-1 (set "r=!r:~,-1!@ ") else set "r=!r! "
- )
- )
- echo;!r!
- endlocal
-
- )
- pause
复制代码 再简单加个循环...噢,我真蛋疼- @echo off & setlocal EnableDelayedExpansion
- mode con:cols=220 lines=80
- :c
- set /a n+=1,m=0,nn=n+1
- setlocal
- for /l %%a in (-%n% 2 %n%) do (
- for /l %%b in (-%n% 1 %nn%) do (
- set /a "m=(%%a*%%a+%%b*%%b-n*n-1)>>31",test=!m!-m
- if !test!==1 (set r%%a=!r%%a!@) else (
- if !test!==-1 (set "r%%a=!r%%a:~,-1!@ ") else set "r%%a=!r%%a! "
- )
- )
- set m=0
-
- )
- cls
- for /l %%a in (-%n% 2 %n%) do echo !r%%a!
- ping /n 1 localhost>nul
- endlocal
- goto c
复制代码 有兴趣的童鞋还可以尝试绘制同心圆 |