Board logo

标题: [数值计算] 已解决 求助批处理命令 set 的乘法运算 [打印本页]

作者: shenlong    时间: 2015-1-19 21:10     标题: 已解决 求助批处理命令 set 的乘法运算

本帖最后由 shenlong 于 2015-5-6 21:48 编辑

1.txt 内容如下:
15
20
13
40

如何让每一个数都乘以 3 然后输出到 2.txt

多谢先!
作者: DAIC    时间: 2015-1-19 22:14

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. (for /f %%i in (1.txt) do (
  4.     set /a n=%%i*3
  5.     echo !n!
  6. ))>2.txt
复制代码

作者: shenlong    时间: 2015-1-20 20:07

多谢了,问题解决了。
我用的是 echo %n% 为何不行,求解。
作者: DAIC    时间: 2015-1-20 21:52

回复 3# shenlong


复合语句内部需要开启变量延迟扩展,参考:
http://bbs.bathome.net/thread-2899-1-1.html
作者: shenlong    时间: 2015-1-21 20:39

回复 4# DAIC


    再次感谢。
作者: pcl_test    时间: 2015-5-4 21:52

问题得到解决后请在标题最前面注明[已解决]
http://www.bathome.net/thread-3473-1-1.html




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2