可_!n!的变量后面楼主你没有用到呵,因你后面用的是变量截取的方法。
不过,字母常量和数字变量一一对应的思路也不错,试编一个:- @echo off&setlocal enabledelayedexpansion
- set "codes=a b c d e f g h i j k l m n o p q r s t u v w x y z"
- for %%a in (%codes%) do set /a n+=1&set "_!n!=%%a"
- set /p input=请输入1-26内的任意数值:
- :lp
- set /a _random=%random%%%26+1,a=_random-input
- if "%a:-=%" lss "2" goto lp
- if %_random% lss %input% (set temp=%input%&set input=%_random%&set _random=!temp!)
- set /a a=input+1,b=_random-1
- set /p=!_%input%!至!_%_random%!间的字母是:<nul
- for /l %%a in (%a%,1,%b%) do (set /p=!_%%a!<nul)
- pause>nul
复制代码
[ 本帖最后由 shqf 于 2009-3-1 23:36 编辑 ] |