1在'for'循环递增落后时格式化技术的原因? [英] Technical reasons behind formatting when incrementing by 1 in a 'for' loop?

查看:88
本文介绍了1在'for'循环递增落后时格式化技术的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有网站上,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.


  1. Denver$c$cr8

  2. 卢卡斯

  3. 添啧啧

  4. User377178

  5. 顽强Techhunter

  1. DenverCoder8
  2. Lucas
  3. Tim Gee
  4. User377178
  5. Tenacious Techhunter

这篇关于1在'for'循环递增落后时格式化技术的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆