贴个笨方法,但是顺序不受限制- @echo off
- setlocal enabledelayedexpansion
-
- set letterstr=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
- echo 请按先后顺序输入两个字母 如:af
- set /p input=
- set index=0
-
- for %%i in (%letterstr%) do (
- if /i "%%i"=="%input:~0,1%" (
- set start=!index!
- )
- if /i "%%i"=="%input:~1,1%" (
- set end=!index!
- )
- set /a index+=2
- )
-
- echo !start!-!end!
- if !end! lss !start! (
- set /a len=!start!-!end!+1
- set start=!end!
- ) else (
- set /a len=!end!-!start!+1
- )
-
- call echo %%letterstr:~!start!,!len!%%
复制代码
|