不能写成 for 循环的 while 循环示例 [英] Example of a while loop that can't be written as a for loop

查看:20
本文介绍了不能写成 for 循环的 while 循环示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 while 循环可以做 for 循环可以做的任何事情,但是 for 循环可以做 while 循环可以做的任何事情吗?

I know a while loop can do anything a for loop can, but can a for loop do anything a while loop can?

请举例说明.

推荐答案

是的,很容易.

while (cond) S;

for(;cond;) S;

这篇关于不能写成 for 循环的 while 循环示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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