1在'for'循环递增落后时格式化技术的原因? [英] Technical reasons behind formatting when incrementing by 1 in a 'for' loop?
问题描述
所有网站上,code样品具有为
循环看起来是这样的:
All over the web, code samples have for
loops which look like this:
for(int i = 0; i < 5; i++)
而我用的格式如下:
while I used the following format:
for(int i = 0; i != 5; ++i)
我这样做,是因为我相信它是更有效,但是这究竟是在大多数情况下,有关系吗?
I do this because I believe it to be more efficient, but does this really matter in most cases?
推荐答案
我已经决定为这个问题越来越显得有些拥挤,列出最翔实的答案。
I have decided to list the most informative answers as this question is getting a little crowded.
<一个href=\"http://stackoverflow.com/questions/1783822/format-of-for-loops/8896521#8896521\">Denver$c$cr8's板凳清楚地标明值得一些认可以及由卢卡斯一个编译版本的循环>。 蒂姆啧啧显示pre和之间的差异;后递增,而 User377178 突出了一些的优点和&LT利弊;和!=。 顽强Techhunter 已经在一般写循环优化,值得一提。
DenverCoder8's bench marking clearly deserves some recognition as well as the compiled versions of the loops by Lucas. Tim Gee has shown the differences between pre & post increment while User377178 has highlighted some of the pros and cons of < and !=. Tenacious Techhunter has written about loop optimizations in general and is worth a mention.
有你有我的前5名的答案。
There you have my top 5 answers.
- DenverCoder8
- Lucas
- Tim Gee
- User377178
- Tenacious Techhunter
这篇关于1在'for'循环递增落后时格式化技术的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!