set /a titleran=0
set /a titleran+=(%RANDOM%*5/32768)+1)
if %titleran%==1 title The Lands of Sweet v.a.0: Now with basic functions
if %titleran%==2 title The Lands of Sweet v.a.0: Hey! Look behind you!
if %titleran%==3 title The Lands of Sweet v.a.0: The Lands of Sweet v.a.0: The Lands of Sweet v.a.0: The Lands of Sweet v.a.0:
if %titleran%==4 title The Lands of Sweet v.a.0: insert funny joke here
if %titleran%==5 title The Lands of Sweet v.a.0: Thots are temporary, The Sweet is eternal
这是生成 1-5 之间的随机数然后根据所选数字设置标题的代码
顺便说一句,它实际上只显示第五个标题
然而,一个更简单的方法:
@Echo Off
Set "titles={Now with basic functions}{Hey! Look Behind You!}{The Lands of Sweet v.a.0: The Lands of Sweet v.a.0: The Lands of Sweet v.a.0:}{insert funny joke here}{Thots are temporary, The Sweet is eternal}"
For /F "Delims=" %%# in ('Set /A "t#=%Random% %%5 + 1"') Do Set "Title=For /F "Tokens=%%# Delims={}" %%t in ("%titles%") Do Title %%t"
%Title%
将可能的标题定义为一个列表,并从列表中提取一个带有随机索引号的标题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句