当前位置 博文首页 > 处理判断字符串长度的代码

    处理判断字符串长度的代码

    作者:admin 时间:2021-02-19 12:02

    呵呵大家也看到题目--基础练习。我不会出的太难的,这道题的思路应该会比较多的
    不过我也还没开始做,希望大家积极参与哦。(最惨的就是只能加别人两分,郁闷)
    习题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
    js