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语句更紧凑。
posted on 2015-03-28 16:54 xiaowuyaliu 阅读(93) 评论(0) 收藏 举报
浙公网安备 33010602011771号