windows 在批处理文件编程中使用“for”循环显示前 N 个自然数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3733883/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using a 'for' loop in batch file programming to display the first N natural numbers
提问by Sarika.S
I would like to mainly know the working of a for
loop. For this I think a small sample program will be helpful to me. So what is a simple program to display the first N natural numbers?
我想主要了解一个for
循环的工作原理。为此,我认为一个小示例程序会对我有所帮助。那么显示前N个自然数的简单程序是什么?
回答by Ramon Araujo
If you are talking about Windows batch programming here you have a natural numbers generator:
如果你在这里谈论 Windows 批处理编程,你有一个自然数生成器:
for /L %i IN (0,1,9) do @echo %i
Other helpful links to deal with files and so on:
处理文件等的其他有用链接:
If you are talking about GNU Linux/Unix bash scripting you can go to:
如果你在谈论 GNU Linux/Unix bash 脚本,你可以去:
Hope that helps,
希望有所帮助,