C语言学习(一)

来源:互联网 发布:淘宝banner图描述 编辑:程序博客网 时间:2024/04/27 15:07

for和while的区别

The choice between while and for is arbitrary, based on which seems clearer. The for is usually appropriate for loops in which the initialization and increment are single statements and logically related, since it is more compact than while and it keeps the loop control statements together in one place.

至于在while与for这两个循环语句中使用哪一个,这是随意的,主要看使用哪一个更能清楚 地描述问题。for语句比较适合描述这样的循环:初值和增量都是单个语句并且是逻辑相关的, 因为for语句把循环控制语句放在一起,比while语句更紧凑。


原创粉丝点击