C++ 關鍵詞: while
來自 cppreference.com
[編輯] 用法
[編輯] 示例
執行此程式碼
#include <iostream> int main() noexcept { int i{3}; // The following 'while' loop statement: // 1. (condition) Checks if value of the variable 'i' is greater than zero // and if not, ends the loop execution with end of this point. // Post-decrements the variable 'i' (decreases its value by 1). // 2. (statement) Writes out a current value of the variable 'i' to the stdout. // 3. Returns to the point 1 (condition). while (i --> 0) // condition: i-- > 0 std::cout << i; // statement: std::cout << i; }
輸出
210
[編輯] 參閱
|
(C++17 起) |
|
(C++23 起) |
- switch 語句:
switch
,case
- default (作為 case 標籤宣告) 等:
default
- goto 語句:
goto
- continue 語句:
continue
- break 語句:
break
- return 語句:
return
(C++20 起) |