关于循环的问题 [英] question about loops

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

问题描述

做什么循环有什么区别?

解决方案

检查这个答案链接。


< blockquote>你有没有打扰过写这两个循环?我打赌你没有。只使用循环的名称可以澄清您的问题: Do While While Do (通常称为 while 循环)。



1。做什么 - 做 *某事* *这是真的*

  
{
// 这里有什么
}
/ * 这是真的* /



2。在做 - 而 *这是真的* *某事*

  while  / *  这是真的* / 
{
// 做什么在这里
}







在Do While循环中,首先执行循环体,然后检查条件。



在While(或While Do as you called)循环中,首先检查条件,然后运行体循环。


同时:



do while循环在检查while的条件之前执行一次循环的内容。



过程如下:

。在循环体中运行代码。

2.检查条件。若是真的,请转到第1步。否则,请继续。









while循环将在执行内容之前先检查条件。



程序如下:

1.检查条件。如果是,请转到步骤2.否则,继续。

2.运行循环体中的代码。

3.转到第1步。


What is the difference between do while and while do loop?

解决方案

Check this answer of this link.


Have you ever bothered writing those 2 loops ? I bet you have not. Your question can be clarified using only the names of the loops: Do While and While Do(usually called the while loop).

1. Do While - Do *something* while *this is true*

do
{
   //what's here
}
while(/*this is true*/)


2. While Do - While *this is true* Do *something*

while(/*this is true*/)
{
   //do what's here
}




In the Do While loop, first the loop body is executed and then the condition is checked.

In the While (or While Do as you called) loop, first the condition is checked and then runs the body loop.


Do While:

The do while loop executes the content of the loop once before checking the condition of the while.

Procedure goes like this:
. Run the code in the body of the loop.
2. Check the condition. If it's true, go to step 1. Otherwise, move on.



While:
A while loop will check the condition first before executing the content.

Procedure goes like this:
1. Check the condition. If it's true, go to step 2. Otherwise, move on.
2. Run the code in the body of the loop.
3. Go to step 1.


这篇关于关于循环的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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