本帖最后由 pcl_test 于 2016-12-6 04:53 编辑
回复 4# tuquan - @echo off&setlocal enabledelayedexpansion
- set start=07:30:00
- set end=08:30:00
- for /f "delims=" %%a in ('wmic path win32_operatingsystem get LocalDateTime /value ^| findstr "="') do set %%a
- set /a "a=(1%start:~,2%-100)*3600+(1%start:~3,2%-100)*60, b=(1%end:~,2%-100)*3600+(1%end:~3,2%-100)*60"
- for /f "tokens=1,2 delims==" %%a in ('more +22 "%~f0"') do set _%%a=%%b&set "#!random!_%%a=%%a"
- for /f "tokens=2 delims==" %%a in ('set #') do set /a n+=1&set #!n!=%%a
- set /a c=(b-a-2)/n
- (for /l %%i in (1 1 %n%) do (
- set /a "r=!random!%%(c/2)+(c/2+1)"
- for /f "tokens=1-3 delims=:" %%a in ("!start!") do (
- set /a h=1%%a-100,m=1%%b-100,s=1%%c-100
- for %%d in (s m h) do (
- set /a "v=%%d,%%d=(%%d+r)%%60,r=(v+r)/60"
- )
- set /a h=100+h,m=100+m,s=100+s,i+=1
- set start=!h:~-2!:!m:~-2!:!s:~-2!
- set /p=time="%LocalDateTime:~0,4%-%LocalDateTime:~4,2%-%LocalDateTime:~6,2% !start!"
- for %%j in (#!i!) do for %%k in (!%%j!) do echo; id="%%k" name="!_%%k!"
- )
- ))<nul
- pause&exit
- 1=陈一
- 2=黄二
- 3=张三
- 4=李四
- 5=王五
- 6=赵六
- 7=钱七
- 8=孙八
- 9=杨九
- 10=吴十
复制代码
|