![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-05 19:27 |
48,039 topics / 350,124 posts / today 2 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » [Solved] Question about using a batch file to calculate the sum of numbers within 100 |
| Printable Version 787 / 5 |
| Floor1 icyheart | Posted 2007-09-06 10:13 |
| 中级用户 Posts 81 Credits 216 | |
|
I want to use a batch file to calculate the sum of numbers within 100, but I just couldn't figure it out. I thought about using a loop for a long time, but got no results, none of it worked, so I'm here to ask everyone for advice.
[ Last edited by icyheart on 2007-9-6 at 10:51 AM ] |
|
| Floor2 xxi | Posted 2007-09-06 10:24 |
| 初级用户 Posts 24 Credits 48 | |
| Floor3 icyheart | Posted 2007-09-06 10:45 |
| 中级用户 Posts 81 Credits 216 | |
|
Thanks, I never thought about it the other way around. What I kept thinking of was for /l %%i in (1,1,100)........ I kept thinking along those lines and just couldn't get it out, hehe thanks
|
|
| Floor4 ccwan | Posted 2007-09-06 10:47 |
| 金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊 | |
|
Can't it work in the forward direction?
|
|
| Floor5 icyheart | Posted 2007-09-06 10:50 |
| 中级用户 Posts 81 Credits 216 | |
|
@echo off
for /l %%i in (1,1,100) do ( set /a sum+=%%i ) echo %sum% By analogy, this works too, hehe |
|
| Floor6 jmz573515 | Posted 2007-09-07 07:39 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
A dumb method, writing one...
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |