死循环 - 顶部或底部? [英] Infinite loops - top or bottom?

查看:126
本文介绍了死循环 - 顶部或底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在像做你的循环测试在顶部或底部:

你使用哪种样式的的无限的循环,为什么?


  • 而(真){}

  • 请{},而(真);

  • 为(;;){}

  • 标签:...转到标号;


解决方案

 ,而(真){}

看起来最有效地传达循环的含义。

In the spirit of questions like Do your loops test at the top or bottom?:

Which style do you use for an infinite loop, and why?

  • while (true) { }
  • do { } while (true);
  • for (;;) { }
  • label: ... goto label;

解决方案

while(true) {}

It seems to convey the meaning of the loop most effectively.

这篇关于死循环 - 顶部或底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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