网站首页  英汉词典

请输入您要查询的英文单词:

 

单词 Do while loop
释义

Do while loop

中文百科

Do-while循环

do-while循环执行过程

zh:zh|do-while循环 do-while循环(do while loop),也有称do循环,是计算机编程语言中的一种控制流程语句。主要由一个代码块(作为循环体)和一个表达式(作为循环条件)组成,表达式为布尔(boolean)型。循环体内的代码执行一次后,进程会去判断这个表达式的返回值,如果这个表达式的返回值为“true”(即满足循环条件)时,则循环体内的代码会反复执行,直到表达式的返回值为“false”(即不满足循环条件)时终止。进程会在每次循环体每执行一次后,进行一次表达式的判断。

一般情况下,do-while循环与while循环相似。两者唯一的分别:do-while循环将先会执行一次循环体内的代码,再去判断循环条件。所以无论循环条件是否满足,do-while循环体内的代码至少会执行一次。因此,do-while循环属于后测循环(post-test loop)。

英语百科

Do while loop Do-while循环

Do While loop flow diagram

In most computer programming languages, a do while loop is a control flow statement that executes a block of code at least once, and then repeatedly executes the block, or not, depending on a given boolean condition at the end of the block.

The do while construct consists of a process symbol and a condition. First, the code within the block is executed, and then the condition is evaluated. If the condition is true the code within the block is executed again. This repeats until the condition becomes false. Because do while loops check the condition after the block is executed, the control structure is often also known as a post-test loop. Contrast with the while loop, which tests the condition before the code within the block is executed, the do-while loop is an exit-condition loop. This means that the code must always be executed first and then the expression or test condition is evaluated. If it is true, the code executes the body of the loop again. This process is repeated as long as the expression evaluates to true. If the expression is false, the loop terminates and control transfers to the statement following the do-while loop. In other words, whereas a while loop sets the truth of a statement as a condition precedent for the code's execution, a do-while loop provides for the action's ongoing execution subject to defeasance by the condition's falsity, which falsity (i.e., the truth of the condition's negation) is set as a condition subsequent.

随便看

 

英汉网英语在线翻译词典收录了3779314条英语词汇在线翻译词条,基本涵盖了全部常用英语词汇的中英文双语翻译及用法,是英语学习的有利工具。

 

Copyright © 2004-2024 encnc.com All Rights Reserved
更新时间:2025/6/19 19:55:20