[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
只要明白set /a的特性就能简洁明了的解答此题了。
  1. If you use any of the logical or modulus operators, you will need to
  2. enclose the expression string in quotes.  Any non-numeric strings in the
  3. expression are treated as environment variable names whose values are
  4. converted to numbers before using them.  If an environment variable name
  5. is specified but is not defined in the current environment, then a value
  6. of zero is used.  This allows you to do arithmetic with environment
  7. variable values without having to type all those % signs to get their
  8. values.
复制代码
心绪平和,眼藏静谧。

TOP

  1. @echo off
  2. Set "a=%random%" & set "b=%random%"
  3. echo %a% %b%
  4. set /a b=%a%,a=%b%
  5. echo %a% %b%
  6. pause
  7. Set "a=%random%" & set "b=%random%"
  8. echo %a% %b%
  9. set /a b=a,a=b
  10. echo %a% %b%
  11. pause
复制代码
希望可以通过如上代码了解到set /a的特性。
1

评分人数

    • rat: 不知道PB + 3
心绪平和,眼藏静谧。

TOP

返回列表