这次效果上没问题了(不用全屏):- @echo off&setlocal enabledelayedexpansion
- set /p l=请输入正方形的边长(小于46的偶数):
- set /a g=l/2,kk=40-l/2,l1=l-1,g1=g-2,s1=l,s2=s1+g1,s3=s2+l
- for /l %%a in (1,1,%kk%) do set "kkk=!kkk! "
- for /l %%a in (1,1,%l1%) do set "k1=!k1! "
- for /l %%a in (1,1,%l%) do (
- set /a n+=1&set "_!n!=."
- set "str=!str!."
- )
- for /l %%a in (1,1,%g1%) do set /a n+=1&set "_!n!=%k1%."
- for /l %%a in (1,1,%l%) do (
- set /a a=l-%%a
- for /l %%b in (1,1,!a!) do set "k2=!k2! "
- for /l %%c in (1,1,%%a) do set ".=!.!."
- set /a n+=1&set "_!n!=!k2!!.!"&set "k2="&set ".="
- )
- set /a n+=g1
- for /l %%a in (1,1,%n%) do (
- for /l %%b in (1,1,%%a) do (
- if %%b leq %s1% (
- if %%b equ 1 set /p=%kkk%<nul>temp
- set /p=!_%%b!<nul>>temp
- if %%b equ %s1% echo.>>temp
- ) else (
- if %%b leq %s2% (
- echo %kkk%!_%%b!>>temp
- ) else (
- set "flag=a"
- if %%b geq %s3% set "ok=a"
- )
- )
- )
- if defined ok (
- echo %kkk%%str%>>temp
- ) else (
- if defined flag echo %kkk%!_%%a!>>temp
- )
- for /l %%d in (1,1,50) do echo>nul
- cls&type temp
- if %%a gtr %s3% (
- set /a a=s2+s3-%%a
- for /l %%e in (%s2%,-1,!a!) do set "a=!_%%e!"&set "a=.!a:~1!"&set "_%%e=!a!"
- )
- )
- pause>nul&del /q temp
复制代码
[ 本帖最后由 batman 于 2009-3-6 00:32 编辑 ] |