while(1){ } 即 WHILE(1); 是什么意思需要循环多久 while(1)和while(1);的区别是什么?

while\uff081\uff09{ } \u5373 WHILE(1); \u662f\u4ec0\u4e48\u610f\u601d

1\u5c31\u662ftrue
while\uff081\uff09\u548cwhile(true)\u662f\u4e00\u4e2a\u610f\u601d,\u5c31\u662f\u65e0\u9650\u5faa\u73af,\u4e00\u822c\u5728\u5185\u90e8\u5199break\u9000\u51fa\u5faa\u73af.

\u7528\u6cd5\u4e3e\u4f8b: \u5982\u679c\u53d8\u91cf i \u7b49\u4e8e100\u662f\u5df2\u77e5\u6761\u4ef6.
\u90a3\u4e48C#\u5c31\u8fd9\u6837\u5199,
while(i==100)
{
i++;
if(i==150) bread; // \u5faa\u73af50\u6b21\u9000\u51fa\u5faa\u73af

}

while(1)\uff5b\u2026\u2026\uff5d\u662f\u8ba9\u5355\u7247\u673a\u4e00\u76f4\u6267\u884c\uff5b\u2026\u2026\uff5d\u4e2d\u5185\u5bb9\uff0c\u9632\u6b62\u7a0b\u5e8f\u8dd1\u98de\uff0c\u901a\u5e38\u7528\u4e8e\u4e3b\u7a0b\u5e8f\u4e3b\u4f53\uff0c\u786e\u4fdd\u7a0b\u5e8f\u6301\u7eed\u6267\u884c
while(1);\u662f\u4e00\u6761\u6307\u4ee4\uff0c\u5b83\u8ba9\u5355\u7247\u673a\u505c\u5728\u8fd9\u4e2a\u4f4d\u7f6e\uff0c\u4e00\u822c\u7528\u6765\u68c0\u6d4b\u4e2d\u65ad,\u53ea\u6709cpu\u6536\u5230\u4e2d\u65ad\u6307\u4ee4\uff0c\u624d\u4f1a\u8df3\u51fawhile(1)\uff0c\u8fdb\u5165\u4e2d\u65ad\u670d\u52a1\u5b50\u7a0b\u5e8f\uff1b
\u4f60\u53ea\u8981\u8bb0\u4f4fwhlie(1)\u672c\u8d28\u662f\u6b7b\u5faa\u73af\uff0cwhile(1)\u4e2d\u7684\u6307\u4ee4\u4f1a\u4e0d\u65ad\u91cd\u590d\u6267\u884c\uff0c\u9664\u975e\u6709\u4e2d\u65ad\uff0cwhile(1);\u53ef\u4ee5\u770b\u4f5cwhile(1){//\u7a7a\u6307\u4ee4}\uff0c\u5b83\u6267\u884c\u7684\u662f\u7a7a\u6307\u4ee4\uff0c\u4e8e\u662f\u5355\u7247\u673a\u5c31\u505c\u5728\u8fd9\u884c\u4ee3\u7801\u5904

就是永远循环的意思。
while是当条件为真(就是为1)是执行{}中的指令,而这条指令{}为空,就是什么都不执行,而条件永远为真,所以程序就一直在这里执行,不向下走了。

和java,c#里的while(true)一个意思,永远循环直到没电...也可能是明天

扩展阅读:www.sony.com.cn ... while 1 是无限循环吗 ... while(1)和while(0) ... when while as 顺口溜 ... do while 0 ... while true ... while 1 什么意思 ... xboxone欧版 ... while 中文翻译 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网