復(fù)制代碼 代碼如下:
::比如我輸入 af 就顯示
::a
::b
::c
::d
::e
::f
::每個字母占一行啊``不知能不能實現(xiàn)..
@echo off
::
::
:begin
cls
set str=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
set input=
set /p input= 請輸入字母范圍(如af):
call set str=%%str:%input:~0,1%=-☆%input:~0,1%%%
call set str=%%str:%input:~-1%=%input:~-1%☆%%
for /f "tokens=2 delims=☆" %%i in ("%str%") do set str=%%i
for %%i in (%str%) do echo %%i
pause
goto begin
@echo off
::
::
set str=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
:begin
cls
set flag=0
set var=
set input=
set /p input= 請輸入字母范圍(如af):
for %%i in (%str%) do call :pickup %%i
:end
pause
goto begin
:pickup
if /i "%1"=="%input:~0,1%" set flag=1
if /i "%1"=="%input:~-1%" set flag=2
if %flag% equ 1 echo %1
if %flag% equ 2 echo %1goto end
goto :eof
@echo off
:: 先把字符串的每一個元素編碼,然后再轉(zhuǎn)換
::
::
setlocal enabledelayedexpansion
set str=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 %%i in (%str%) do set/a dec+=1 set %%i=!dec! set str!dec!=%%i
set en=
set /p en=請輸入字母范圍(如af):
set/a num1=!%en:~0,1%!,num2=!%en:~-1%!
for /l %%i in (%num1%,1,%num2%) do echo !str%%i!
pause>nul
goto :eof
@echo off
:: 通過比較字符內(nèi)部編碼的大小來實現(xiàn),局限性很大
::
::
setlocal enabledelayedexpansion
set str=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
set en=
set /p en=請輸入字母范圍(如af):
set str1=%en:~0,1%
set str2=%en:~-1%
for %%i in (%str%) do if %%i geq !str1! if %%i leq !str2! echo %%i
pause>nul
goto :eof
@echo off
:: 缺點:速度比較慢
::
::
:begin
set /p a="老規(guī)矩 嘻嘻 :"
set str=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 %%i in (%str%) do echo %%i|findstr [%a:~0,1%-%a:~-1%]
pause
goto begin