- @echo off
- SetLocal EnableDelayedExpansion
- set "var= abcdefghijklmnopqrstuvwxyz"
- set /p Get_var=
- set bc=%random%%random%%random%
- set count=1
- :Count
- if %count% lss 27 (
- if "!var:~%count%,1!" equ "!Get_var!" set /a Num1=count
- set /a count+=1
- goto :Count
- )
- set/p,=!Num1! <nul
- :GetRan
- set /a Ran=%random%%%26+1
- set/p,=!Ran!<nul
- set /a Tem=Ran-Num1
- if %Tem% lss 0 (set /a n1=Ran+1,n2=Num1-Ran-1) else (if %Tem% gtr 0 (set /a n1=Num1+1,n2=Tem-1) else (goto :GetRan))
-
- :Print
- echo. !var:~%n1%,%n2%!
复制代码 看似简单,其实有点难度...
在获取输入字母的编号时是不是还有什么好方法呢?
嗯...搞了那么久原来搞复杂了...囧.
[ 本帖最后由 BBCC 于 2009-2-28 22:26 编辑 ] |