是否有一个技术理由使用&GT; (小于)!而不是=在'for'循环递增1时? [英] Is there a technical reason to use > (<) instead of != when incrementing by 1 in a 'for' loop?
本文介绍了是否有一个技术理由使用&GT; (小于)!而不是=在'for'循环递增1时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我几乎再也看不到为
循环是这样的:
的for(int i = 0;!5 =我++ I)
{}
有没有技术理由使用&GT;
或&LT;
而不是! =
1在递增为
循环什么时候?或者,这更是一个约定?
解决方案
同时(时间!=下午6:30){
工作();
}
这是下午6时31 ......妈的,现在我的下一个机会回家的明天! :)
这表明较强的限制,减轻风险,并可能更直观的了解。
I almost never see a for
loop like this:
for (int i = 0; 5 != i; ++i)
{}
Is there a technical reason to use >
or <
instead of !=
when incrementing by 1 in a for
loop? Or this is more of a convention?
解决方案
while (time != 6:30pm) {
Work();
}
It is 6:31pm... Damn, now my next chance to go home is tomorrow! :)
This to show that the stronger restriction mitigates risks and is probably more intuitive to understand.
这篇关于是否有一个技术理由使用&GT; (小于)!而不是=在'for'循环递增1时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文