|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『楼 主』:
 批处理计算1+2+3+4……100的值
 
使用 LLM 解释/回答一下 
 
 
高一数学书必修三居然学编程……无奈……爽。好多数学题我都不能用bat做很不爽,所以选了一道好点的,1+2+3……100貌似简单,但还是要用上点技巧的。直接用set /a n=(1+100)*100/2 太没趣。写了代码
 
 @echo off
 set a=0
 set b=0
 :a
 echo.+%a%=%b%
 set /a a+=1
 set /a b=%b%+%a%
 if %a% gtr 100 (pause) else (goto :a)
 exit
 
 ::结合了for的
 @echo off
 setlocal ENABLEDELAYEDEXPANSION
 set b=0
 for /l %%a in (1,1,100) do (
 set /a b=%%a+!b!
 echo %%a !b!
 )
 pause
 
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\这个比较视觉感
 
 @echo off
 set /a a=1,b=0
 :a
 set b=%b%+%a%
 set /a a+=1
 echo %b%
 ping -n 1 127.0>nul
 cls
 if %a% gtr 100 (goto :b) else (goto :a)
 :b
 set /a c=%b%
 echo.%b%=%c%
 pause
 
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\2
 
 @echo off
 set /a a=1,b=0
 :a
 set b=%b% +%a%
 set /a a+=1
 echo %b%
 cls
 if %a% gtr 100 (goto :b) else (goto :a)
 :b
 set /a c=%b%
 echo.%b%=%c%
 pause
 
High school mathematics book required three actually learns programming... Helpless... Happy. Many math problems I can't do with bat, very unhappy, so I chose a better one. 1+2+3...100 seems simple, but still need to use some skills. Directly using set /a n=(1+100)*100/2 is too boring. Wrote the code
 @echo off
 set a=0
 set b=0
 :a
 echo.+%a%=%b%
 set /a a+=1
 set /a b=%b%+%a%
 if %a% gtr 100 (pause) else (goto :a)
 exit
 
 ::Combined with for
 @echo off
 setlocal ENABLEDELAYEDEXPANSION
 set b=0
 for /l %%a in (1,1,100) do (
 set /a b=%%a+!b!
 echo %%a !b!
 )
 pause
 
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\This is more visual sense
 
 @echo off
 set /a a=1,b=0
 :a
 set b=%b%+%a%
 set /a a+=1
 echo %b%
 ping -n 1 127.0>nul
 cls
 if %a% gtr 100 (goto :b) else (goto :a)
 :b
 set /a c=%b%
 echo.%b%=%c%
 pause
 
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\2
 
 @echo off
 set /a a=1,b=0
 :a
 set b=%b% +%a%
 set /a a+=1
 echo %b%
 cls
 if %a% gtr 100 (goto :b) else (goto :a)
 :b
 set /a c=%b%
 echo.%b%=%c%
 pause
 
 
 
 
 |  
                  |  综合型编程论坛
 
 我的作品索引
 |  | 
|  2008-2-24 12:48 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 2 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
是像我这种菜菜学习for和set的好例子哦! 
This is a good example for a newbie like me to learn for and set! 
 
 
 |  | 
|  2008-2-24 12:49 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
|   『第 3 楼』:
 顺便在这里发我的原创批量重命名了哈
 
使用 LLM 解释/回答一下 
 
 
cn-dos论坛看到好多好的批量重命名批处理,但高手们都用上了set    ……   我不懂,所以做了自己看得懂的,不过效率就比较低了。没有用上set命令哦!
 \\\\\\\\\\\\\\\\\\\\\\\\\\\批量重命名1.bat    \\\\\\\\\\\\\\\(重命名为1 2 3 ……10 11 这类的)
 
 @echo off
 ren *.jpg *.[jpg]
 for /l %%a in (1,1,10000) do (
 ren *.[jpg] final-%%a.jpg
 if not exist *.[jpg] cls &color 0b &echo OK!! &pause &exit
 )
 
 \\\\\\\\\\\\\\\\\\\\\\\\\\\批量重命名2.bat    \\\\\\\\\\\\\\\ (重命名为001 002 003 ……这类的)
 
 @echo off
 ren *.jpg *.[jpg]
 for %%a in (0 1 2 3 4 5 6 7 8 9) do (
 for %%b in (0 1 2 3 4 5 6 7 8 9) do (
 for %%c in (0 1 2 3 4 5 6 7 8 9) do (
 color %%b%%c
 ren *.[jpg] final-%%a%%b%%c.jpg
 if not exist *.[jpg] cls &color 0b &echo OK!! &pause &exit
 )
 )
 )
 
 
 \\\\\\\\\\\\\\\\\\\\\\\\\批量重命名终版.bat \\\ (可以自己现则类型,文件类型,重命名序号的开头,如a001,a002)
 
 ::如有不足之处(可以做到改善的) 欢迎来投诉或改正   hi.baidu.com/523066680
 
 @echo off
 mode con cols=77 lines=12
 title 某批处理初学者 hi.baidu.com/523066680
 color 0b
 
 ::======================================================================
 
 echo.
 echo.步骤一、在这里输入新文件名的开头 可直接回车(即命名为000 001 002)或(0 1 2)
 echo.        如输入a 则会重命名为a000 a001 a002.....或 a0 a1 a2......
 echo.
 echo.不支持特殊符号 ^> ^< ^\ ^/ ^? ^" ^: ^| ^* 输入名字后不能输空格,该批处理不判断.
 echo.
 set /p no1=请输入:
 
 ::======================================================================
 
 cls
 echo.
 echo.步骤二、在这里输入将被重命名文件的格式
 echo.
 echo.
 echo.不支持特殊符号 ^> ^< ^\ ^/ ^? ^" ^: ^| ^* 空格,或是直接回车。该批处理不判断.
 echo.&echo.
 set /p no2=请输入:
 if not exist *.%no2% (cls &echo 不存在%no2%格式的文件,请正确输入,按任意键退出 &pause>nul &exit)
 if /i %no2%==bat (cls &echo 不支持重命名bat格式文件(本文件会被重命名,导致....) &pause &exit)
 cls
 
 ::======================================================================
 
 :Second
 cls
 echo.执行的时候显示“存在一个重名文件,或是找不到文件”请不要马上关闭,等待执行
 echo.
 echo.选择模式a:重命名成000 001 002,限制为999个文件(可更改)
 echo.选择模式b:重命名为1 2 3 4 5 ....,限制为10000个文件(可更改)
 echo.
 set /p action="在此输入:"
 if /i "%action%"=="a" (goto :ren1-1)
 if /i "%action%"=="b" (goto :ren2-1) else (goto :second)
 
 ::======================================================================
 
 
 :ren1-1
 cls
 ren *.%no2% *.[%no2%]
 
 for %%a in (0 1 2 3 4 5 6 7 8 9) do (
 for %%b in (0 1 2 3 4 5 6 7 8 9) do (
 for %%c in (0 1 2 3 4 5 6 7 8 9) do (
 color %%b%%c &title %%a%%b%%c.%no2%
 echo.                                 %no1%%%a%%b%%c.%no2%
 ren *.[%no2%] %no1%%%a%%b%%c.%no2%>nul 2>nul
 if not exist *.[%no2%] cls &color 0b &echo OK!! &pause &exit
 )
 )
 )
 
 ::=======================================================================
 
 :ren2-1
 ren *.%no2% *.[%no2%]
 for /l %%a in (1,1,10000) do (
 echo.                                 %no1%%%a%no2%
 ren *.[%no2%] %no1%%%a.%no2%>nul 2>nul
 if not exist *.[%no2%] cls &color 0b &echo OK!! &pause &exit
 )
 
cn-dos forum saw many good batch renaming batch processing, but the experts all used set... I don't understand, so I made one that I can understand, but the efficiency is relatively low. I didn't use the set command!
 \\\\\\\\\\\\\\\\\\\\\\\\\\Batch Rename 1.bat \\\\\\\\\\\\\\\ (Rename to 1 2 3...10 11, etc.)
 
 @echo off
 ren *.jpg *.
 for /l %%a in (1,1,10000) do (
 ren *. final-%%a.jpg
 if not exist *. cls &color 0b &echo OK!! &pause &exit
 )
 
 \\\\\\\\\\\\\\\\\\\\\\\\\\Batch Rename 2.bat \\\\\\\\\\\\\\\ (Rename to 001 002 003..., etc.)
 
 @echo off
 ren *.jpg *.
 for %%a in (0 1 2 3 4 5 6 7 8 9) do (
 for %%b in (0 1 2 3 4 5 6 7 8 9) do (
 for %%c in (0 1 2 3 4 5 6 7 8 9) do (
 color %%b%%c
 ren *. final-%%a%%b%%c.jpg
 if not exist *. cls &color 0b &echo OK!! &pause &exit
 )
 )
 )
 
 
 \\\\\\\\\\\\\\\\\\\\\\\\\Final Batch Rename.bat \\\ (Can choose the type, file type, start of the rename sequence, such as a001, a002)
 
 ::If there are deficiencies (that can be improved), welcome to complain or correct hi.baidu.com/523066680
 
 @echo off
 mode con cols=77 lines=12
 title A batch processing beginner hi.baidu.com/523066680
 color 0b
 
 ::======================================================================
 
 echo.
 echo.Step 1: Enter the beginning of the new file name here, you can directly press Enter (that is, rename to 000 001 002) or (0 1 2)
 echo.        If you enter a, it will be renamed to a000 a001 a002..... or a0 a1 a2......
 echo.
 echo.Special symbols ^> ^< ^\ ^/ ^? ^" ^: ^| ^* are not supported. Do not enter spaces after entering the name. This batch processing does not judge.
 echo.
 set /p no1=Please enter:
 
 ::======================================================================
 
 cls
 echo.
 echo.Step 2: Enter the format of the file to be renamed here
 echo.
 echo.
 echo.Special symbols ^> ^< ^\ ^/ ^? ^" ^: ^| ^* spaces are not supported, or directly press Enter. This batch processing does not judge. &echo.
 set /p no2=Please enter:
 if not exist *.%no2% (cls &echo There is no file in %no2% format, please enter correctly, press any key to exit &pause>nul &exit)
 if /i %no2%==bat (cls &echo Renaming bat format files is not supported (this file will be renamed, resulting in....) &pause &exit)
 cls
 
 ::======================================================================
 
 :Second
 cls
 echo.When executing, if it shows "There is a duplicate file or the file is not found", please do not close it immediately, wait for execution
 echo.
 echo.Select mode a: Rename to 000 001 002, limited to 999 files (can be changed)
 echo.Select mode b: Rename to 1 2 3 4 5 ...., limited to 10000 files (can be changed)
 echo.
 set /p action="Enter here:"
 if /i "%action%"=="a" (goto :ren1-1)
 if /i "%action%"=="b" (goto :ren2-1) else (goto :second)
 
 ::======================================================================
 
 
 :ren1-1
 cls
 ren *.%no2% *.
 
 for %%a in (0 1 2 3 4 5 6 7 8 9) do (
 for %%b in (0 1 2 3 4 5 6 7 8 9) do (
 for %%c in (0 1 2 3 4 5 6 7 8 9) do (
 color %%b%%c &title %%a%%b%%c.%no2%
 echo.                                 %no1%%%a%%b%%c.%no2%
 ren *. %no1%%%a%%b%%c.%no2%>nul 2>nul
 if not exist *. cls &color 0b &echo OK!! &pause &exit
 )
 )
 )
 
 ::=======================================================================
 
 :ren2-1
 ren *.%no2% *.
 for /l %%a in (1,1,10000) do (
 echo.                                 %no1%%%a%no2%
 ren *. %no1%%%a.%no2%>nul 2>nul
 if not exist *. cls &color 0b &echo OK!! &pause &exit
 )
 
 
 | 此帖被 +3 点积分    点击查看详情 | 评分人:【 abcd 】 | 分数: +3 | 时间:2008-2-24 12:52 | 
 | 
 
 
 
 |  | 
|  2008-2-24 12:50 |  | 
|  | 
 
| everest79 金牌会员
 
       一叶枝头,万树皆春
 
 
 
 积分 2564
 发帖 1127
 注册 2006-12-25
 状态 离线
 | 
| 『第 4 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
FOR /L %variable IN (start,step,end) DO command [command-parameters]
 该集表示以增量形式从开始到结束的一个数字序列。
 因此,(1,1,5) 将产生序列 1 2 3 4 5,(5,-1,1) 将产生
 序列 (5 4 3 2 1)。
 
FOR /L %variable IN (start,step,end) DO command 
 This set represents a sequence of numbers from start to end in increments.
 Therefore, (1,1,5) will generate the sequence 1 2 3 4 5, and (5,-1,1) will generate the sequence (5 4 3 2 1).
 
 
 
 |  | 
|  2008-2-24 13:13 |  | 
|  | 
 
| slore 铂金会员
 
        
 
 
 
 积分 5212
 发帖 2478
 注册 2007-2-8
 状态 离线
 | 
| 『第 5 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
直接用set /a n=(1+100)*100/2 太没趣。
 汗~
 最好的算法。。。最快。
 
It's too boring to just use set /a n=(1+100)*100/2.
 Sweat~
 The best algorithm... the fastest.
 
 
 
 |  | 
|  2008-2-24 14:06 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 6 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
嘿嘿……探究精神,不可少……明明知道有简单的,还是要去做别的方法 
Hehe... The spirit of exploration is indispensable... Clearly knowing there is a simple one, but still wanting to do other methods 
 
 
 |  | 
|  2008-2-24 14:48 |  | 
|  | 
 
| 40szb 初级用户
 
   
 
 
 
 积分 46
 发帖 21
 注册 2006-12-25
 来自 西安
 状态 离线
 |  | 
|  2008-2-24 14:52 |  | 
|  | 
 
| moniuming 银牌会员
 
      永远的菜鸟
 
 
 
 积分 1335
 发帖 574
 注册 2007-11-27
 来自 广西
 状态 离线
 | 
| 『第 8 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
@echo offset aa=0
 for /l %%a in (1,1,100) do (
 call :aaa %%a
 )
 pause
 goto :eof
 :aaa
 set /a aa=%1+%aa%
 echo %aa%
 
```batch@echo off
 set aa=0
 for /l %%a in (1,1,100) do (
 call :aaa %%a
 )
 pause
 goto :eof
 :aaa
 set /a aa=%1+%aa%
 echo %aa%
 ```
 
 
 
 |  | 
|  2008-2-24 14:55 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 9 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
楼上的代码好灵活啊……我学学 
The code upstairs is so flexible... I'll learn it. 
 
 
 |  | 
|  2008-2-24 15:18 |  | 
|  | 
 
| slore 铂金会员
 
        
 
 
 
 积分 5212
 发帖 2478
 注册 2007-2-8
 状态 离线
 | 
| 『第 10 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
@echo offfor /l %%a in (1,1,100) do set /a a+=%%a
 echo %a%
 pause
 
@echo offfor /l %%a in (1,1,100) do set /a a+=%%a
 echo %a%
 pause
 
 
 
 |  | 
|  2008-2-24 16:02 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 11 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
学习了……自愧中……不过还是学习了! 
Learned... Feeling ashamed... But still learned! 
 
 
 |  | 
|  2008-2-24 16:38 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 12 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
我想把11楼的代码弄的视觉一些,但是出现怪现象@echo off
 for /l %%a in (1,1,100) do (
 set /a a+=%%a
 echo.%a%
 )
 pause
 
I want to make the code on floor 11 more visual, but there's a strange phenomenon@echo off
 for /l %%a in (1,1,100) do (
 set /a a+=%%a
 echo.%a%
 )
 pause
 
 
 
 |  | 
|  2008-2-24 16:41 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 13 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
又改了一下……可以了@echo off
 setlocal ENABLEDELAYEDEXPANSION
 for /l %%a in (1,1,100) do (set /a a+=%%a &echo !a!)
 pause
 
It has been modified again... It's okay@echo off
 setlocal ENABLEDELAYEDEXPANSION
 for /l %%a in (1,1,100) do (set /a a+=%%a &echo !a!)
 pause
 
 
 
 |  | 
|  2008-2-24 16:45 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 14 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
九楼的代码我理解不了啊……谁愿意解释下,这里谢谢了 
I can't understand the code on the ninth floor... Who is willing to explain it? Thanks here 
 
 
 |  | 
|  2008-2-24 16:52 |  | 
|  | 
 
| 523066680 银牌会员
 
      SuperCleaner
 
 
 积分 2362
 发帖 1133
 注册 2008-2-2
 状态 离线
 | 
| 『第 15 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
怎么每人离我啊……教下啊! 
Why is everyone leaving me... Teach me! 
 
 
 |  | 
|  2008-3-1 18:19 |  |