处理判断字符串长度的代码
呵呵⼤家也看到题⽬--基础练习。我不会出的太难的,这道题的思路应该会⽐较多的
不过我也还没开始做,希望⼤家积极参与哦。(最惨的就是只能加别⼈两分,郁闷)
习题1.1 字符串长度不超过80。不含特殊字符
例 i like the bathome,because here is the batch of the world.
1.2 字符串长度⼩于255,含有特殊字符,试求其长度。
例 %%a%%!ver!&^^^ ^*~ are you o k ?" : \ / ` ` verfdxcweippo opj x ds gw !%%
⼀般的,先求1.1的题⽬。看谁的代码灵活、简洁、思路清晰。然后再做1.2
(汗。中⽂不⽤考虑……)
其实我也是想征集⼀个⽐较好的办法……估计如果有中⽂的话。或许可以重定向到⽂本然后再判断字节吧。我猜可以的。最后:⼀题多解,可别只⽤重定向⽂本那个⽅法哈。
523066680:
复制代码代码如下:
@echo off字符串长度怎么判断
echo,i like the bathome,because here is the batch of the world.>x.x
for /f "tokens=*" %%a in ('dir x.x /-c ^|find " 字节" ^|find /v ":"') do (
for /f "tokens=3" %%b in ('echo,%%a') do (
set /a n=%%b-2
call echo %%n%%
del x.x
)
)
pause>nul
shqf:
复制代码代码如下:
::%%a%%!ver!&^^^ ^*~ are you o k ?" : \ / ` ` verfdxcweippo opj x ds gw !%%
@echo off&setlocal enabledelayedexpansion
set /p str=<%0
for /l %%a in (1,1,255) do (set str=!str:~1!&if "!str!"=="" (set /a totle=%%a-2&echo !totle!&goto end))
:end
pause
terse:
复制代码代码如下:
@echo off&setlocal enabledelayedexpansion
set/p str=Type :
for /l %%i in (1,1,10000) do if "!str:~%%i,1!"=="" echo %%i&pause&exit

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。