ieutk 当前离线
荣誉版主
@echo off&setlocal enabledelayedexpansion :main cls&echo. set input= set /p input= 请输入字母: if not defined input goto main echo %input%|findstr "^[a-z]*$">nul||goto main call :ya %input% len for /l %%a in (0 1 %len%) do call :ie %%a _num echo. echo 你输入了 "%input%" ,它们的总和为 "%_num%" echo. pause set _num=0 goto main :ya for /f "tokens=1 delims=:" %%a in ('^(echo %1^&echo.^)^|findstr /o ".*"') do set /a %2=%%a-4 goto :eof :: 在随风发的贴子中看到此方法,现学现用,拿来试下 :ie for %%b in (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) do ( set /a num+=1 if "!input:~%1,1!"=="%%b" set /a %2+=!num! ) set num=0 goto :eof复制代码
TOP