标题: 【出题】批处理逐字输出效果练习 [打印本页]
作者: plp626 时间: 2011-8-14 12:48 标题: 【出题】批处理逐字输出效果练习
- THEY CAME FIRST for the Coummunists,
- and I didn't speak up because I wasn' t a Communist.
-
- THEN THEY CAME for the Jews,
- and I didn't speak up because I wasn' t a Jew.
-
- THEN THEY CAME for the trade unionists,
- and I didn't speak up because I wasn' t a trade unionist.
-
- THEN THEY CAME for the Catholics,
- and I didn't speak up because I was a Protestant.
-
- THEN THEY CAME for me,
- and by that time no one was left to speak up.
-
-
-
- Pastor Martin Niemoeller
复制代码
显示速度每分钟200字母;代码尽量短小简洁;(注意文字内有很多重复短语)
作者: CrLf 时间: 2011-8-14 13:02
这里的字是指单词还是字母呢?
作者: plp626 时间: 2011-8-14 13:10
逐字母显示,就像键盘敲代码的效果。。。
作者: lfoqtal 时间: 2011-8-14 14:40
本帖最后由 lfoqtal 于 2011-8-14 14:43 编辑
吃螃蟹呀!
自认为不够精简,输出时间还行啦(包括空格的速度)- @echo off&setlocal enabledelayedexpansion
- for /f "skip=16 delims=" %%a in (%0) do (
- call :1 "%%a"
- set b=0&echo.
- )
- pause<nul
- goto :eof
- :1
- set "a=%~1"
- :2
- if "!a:~%b%,1!"=="" goto :eof
- set/p=!a:~%b%,1!<nul
- set /a b+=1
- for /l %%i in (1,1,100) do a 2>nul
- goto :2
-
- THEY CAME FIRST for the Coummunists,
- and I didn't speak up because I wasn' t a Communist.
-
- THEN THEY CAME for the Jews,
- and I didn't speak up because I wasn' t a Jew.
-
- THEN THEY CAME for the trade unionists,
- and I didn't speak up because I wasn' t a trade unionist.
-
- THEN THEY CAME for the Catholics,
- and I didn't speak up because I was a Protestant.
-
- THEN THEY CAME for me,
- and by that time no one was left to speak up.
-
-
-
- Pastor Martin Niemoeller
复制代码
作者: 545810831 时间: 2011-8-14 17:39
我试一下,做到了分行输出,就是字符之间有空隔,不知谁帮我改一下。- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=" %%i in (1.txt) do (
- set b=%%i
- for /l %%a in (0 1 100) do (
- set/p var=!var!!b:~%%a,1!<nul&set var=
- for /l %%b in (0 1 300) do echo %%b>nul
- )
- )
- pause
-
复制代码
作者: 风之语故乡 时间: 2011-8-16 20:49
回复 4# lfoqtal
win7 下,你的代码空格不显示。
关于我的:- @echo off
- setlocal enabledelayedexpansion
- for /f "skip=37 delims=" %%i in ('findstr /n .* %0') do (
- set "Mstr=%%i"
- set "Mstr=!Mstr:*:=!"
- call :逐字显示
- echo.
- )
- pause>nul
-
- :逐字显示
- call :FunDelay 200
- if defined Mstr (
- set "s=!Mstr:~0,1!"
- if defined s (
- set /p "=@!s!"<nul
- set Mstr=!Mstr:~1!
- goto 逐字显示
- )
- ) else (
- set /p "="<nul
- )
- goto :eof
-
- :FunDelay
- set beginTime=%time%
- set/a minute1=1%beginTime:~3,2%-100
- set/a second1=1%beginTime:~6,2%%beginTime:~-2%0-100000
-
- :LoopContinue
- set nowTime=%time%
- set/a minute2=1%nowTime:~3,2%-100
- set/a second2=1%nowTime:~6,2%%nowTime:~-2%0-100000
- set/a difMs=((%minute2%-%minute1%+60)%%60)*60000+%second2%-%second1%
- if %difMs% lss %1 goto LoopContinue
- goto :eof
-
- THEY CAME FIRST for the Coummunists,
- and I didn't speak up because I wasn' t a Communist.
-
- THEN THEY CAME for the Jews,
- and I didn't speak up because I wasn' t a Jew.
-
- THEN THEY CAME for the trade unionists,
- and I didn't speak up because I wasn' t a trade unionist.
-
- THEN THEY CAME for the Catholics,
- and I didn't speak up because I was a Protestant.
-
- THEN THEY CAME for me,
- and by that time no one was left to speak up.
-
-
-
- Pastor Martin Niemoeller
复制代码
精简肯定是谈不上了,
还有那个延时函数,挺庞大的
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |