此代码回显字符和字符的每一行号,但不完全正确。尝试修复。主要的是变量计数必须保留而不是 %%m。请用电话解释我的行!
以及如何使最后一行显示输入单词的最后一个字符。
@ECHO OFF
:input
set /p word=input your word:
if not defined word goto input
(ECHO %word%)> tempfile.txt
FOR %%x IN (tempfile.txt) DO ( SET /A lenght=%%~zx - 2 )
del tempfile.txt
echo %word% got %lenght% characters
setlocal enabledelayedexpansion
for /l %%m in (1,1,!lenght!) do (
set /a count=0
set /a count=count+%%m
call echo !count! %%word:~!count!,1%%
)
endlocal
pause
所以,这里是输出:
input your word:qwertzuio
qwertzuio got 9 characters
1 w
2 e
3 r
4 t
5 z
6 u
7 i
8 o
9
Press any key to continue...