Skip to content
View in the app

A better way to browse. Learn more.

主视角中国

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

无条件循环&有条件循环

(0 评审)

无条件循环&有条件循环

通常,如果要写一个无限循环,我们可以这么写:

			  while ( 1 ) {

					 /* ... ... */

			  }


    这么写完全正确。不过,while (1) 是一个有条件循环,每次循环都会判断 1 的真假性,

因为 1 永远为真,所以这个循环会无限执行。正因为 while (1) 是有条件循环,

所以在效率上比无条件循环要略孙一筹。哪怎么写无条件循环呢?

很简单。请看:


		 for ( /* 可以有代码 */; /* 必须为空 */; /* 可以有代码 */ ) {

			 /* ... ... */

		 }

上面的代码就是一个无条件循环,每次循环不用进行任何判断,所以效率比 while (1) 高。

来源: C/C++ 标准编程

0 评论

Recommended Comments

没有要显示的评论。

访客
添加评论...

Account

Navigation

搜索

搜索

设置浏览器推送通知

Chrome(安卓)
  1. 点击地址栏旁边的锁形图标。
  2. 点击 权限 → 通知
  3. 根据需要调整通知设置。
Chrome(桌面)
  1. 点击地址栏中的锁形图标。
  2. 选择 网站设置
  3. 找到 通知,然后根据需要调整设置。