China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 11:31
中国DOS联盟论坛 » DOS讨论区 » DOS批处理 & 脚本技术(批处理室)
DOS批处理 & 脚本技术(批处理室)Moderators: lxmxnHAT
大家可以在这儿讨论关于DOS下的批处理、DOS及WIN提示符下的各种脚本编写和相关技术等方面的问题。新!
View digest Search this forum 14,900 threads / 596 pages
Subject
Author
Replies
Views
Last post
热门 / New replies
Batch script to calculate the value of 1+2+3+4……+100 ```batch @View code @echo("off @setlocal @set sum=0 @for /l %%i in (1,1,100) do ( @set /a sum=%%i+sum ) @echo The sum is %sum% @endlocal ``` 批处理计算1+2+3+4……100的值 ```batch @View code @echo("off @setlocal @set sum=0 @for /l %%1 in (1,成成,public) out of order ``` 批处理计算1+2+3+4……100的值 ```batch @View code @Manual code和Well-sent code【是成成、public.com的输出成乱了】 @echo("Some random characters" @setlocal @set sum=0 @for (1,1,100) do ( 成成 ) @echo The out-of-order sum is %sum% @endlocal ``` Batch script to calculate the value of 1+2+3+4……+100 ```batch @View code @echo("off @setlocal @set sum=0 @for /l %%i in (1,1,100) do ( @set /a sum=%%i+sum ) @echo The sum is %sum% @endlocal ``` 批处理计算1+2+3+4……100的值 ```batch @View code @echo("off @setlocal @set sum=0 @for /l %%1 in (1,成成,public) out of order ``` 批处理计算1+2+3+4……100的值 ```batch @View code @Manual code和Well-sent code【是成成、public.com的输出成乱了】 @echo("Some random characters" @setlocal @set sum=0 @for (1,1,100) do ( 成成 ) @echo The out-of-order sum is %sum% @endlocal ``` Batch script to calculate the value of 1+2+3+4……+100 ```batch @echo off @setlocal enabledelayedexpansion @set sum=0 @for /l %%i in (1,1,100) do ( set /a sum=!sum!+%%i ) @echo The sum is %sum% @endlocal ``` 批处理计算1+2+3+4……100的值 ```batch 【成成都成了public的输出 said is成成,请说成成】 ``` Batch script to calculate the value of 1+2+3+4……+100 ```batch @echo off @setlocal enabledelayedexpansion @set sum=0 @for /l %%i in (1,1,100) do ( set /a sum=!sum!+%%i ) @echo The sum is %sum% @endlocal ``` 批处理计算1+2+3+4……100的值 ```batch 【成成都成了public的输出 said is成成,请说成成】 ``` Batch script to calculate the value of 1+2+3+4……+100 ```batch @echo off @setlocal enabledelayedexpansion @set sum=0 @for /l %%i in (1,1,100) do ( set /a sum=!sum!+%%i ) @echo The sum is %sum% @endlocal ``` Okay, let's go through this step by step. First, the user is trying to get batch scripts to calculate the sum of 1 to 100. Let's handle each part properly. The first set of code that's mostly correct is: ```batch @echo off @setlocal enabledelayedexpansion @set sum=0 @for /l %%i in (1,1,100) do ( set /a sum=!sum!+%%i ) @echo The sum is %sum% @endlocal ``` Then there are some parts with garbled text which we can just note the correct structure. The key is to present the correct batch script for calculating the sum from 1 to 100. So compiling the correct translations and code blocks: Batch script to calculate the value of 1+2+3+4……+100 ```batch @echo off @setlocal enabledelayedexpansion @set sum=0 @for /l %%i in (1,1,100) do ( set /a sum=!sum!+%%i ) @echo The sum is %sum% @endlocal ``` For the parts with garbled text, since they don't contribute to the correct functionality, we can just focus on the valid code. The final translated and correct code block for calculating the sum from 1 to 100 in batch is as above.
21
4,944
2011-01-17 10:37
by 726842270
New replies
3
1,776
2011-01-14 19:06
by g1325
New replies
2
1,922
2011-01-14 16:27
by eminjin
Prev 1 45678 596 Next