This commit is contained in:
krahets
2023-11-03 22:49:42 +08:00
parent a04196b789
commit 562ca7dc89
3 changed files with 52 additions and 52 deletions

View File

@ -388,7 +388,7 @@ comments: true
}
```
`while` 循环中,由于初始化和更新条件变量的步骤是独立在循环结构之外的,**因此它比 `for` 循环的自由度更高**。
**`while` 循环比 `for` 循环的自由度更高**。在 `while` 循环中,我们可以自由设计条件变量的初始化和更新步骤
例如在以下代码中,条件变量 $i$ 每轮进行了两次更新,这种情况就不太方便用 `for` 循环实现。