Skip to content

Commit d9306ea

Browse files
authored
Translate 03logic-statements.md
1 parent ddf8b13 commit d9306ea

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

docs/en/quickstart/02base/03logic-statements.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
lastUpdated: true
33
---
44

5-
# 逻辑语句
5+
# Logic statements
66

77
::: tip
8-
MCFPP中的逻辑语句和C/Java中的逻辑语句完全一致。如果你对其他语言足够熟悉,你可以跳过这一节。
8+
The logic statement of MCFPP is totally the same as in C/Java. You can skip this chapter if you already know it.
99
:::
1010

11-
## if语句
11+
## if statement
1212

13-
`if`语句是一种条件语句,它用来判断一个条件是否成立。如果条件成立,那么`if`语句中的代码块将会被执行。`if`语句的语法如下:
13+
`if` statement is a condition statement, it can used to determine a condition is true or false. If true, then the code in the `if` statement block will be execute. The grammar of `if` is:
1414

1515
```mcfpp
1616
if (condition){
1717
#code
1818
}
1919
```
2020

21-
`condition`是一个布尔表达式,它的值为`true``false`。如果`condition`的值为`true`,那么`#code`中的代码块将会被执行。
21+
`condition` is a boolean expression, it’s value is `true` or `false`. If the value of `condition` is `true`, then `#code` will be execute.
2222

23-
`if`语句还可以和`else`语句一起使用,`else`语句用来在`if`语句的条件不成立时执行代码块。`if-else`语句的语法如下:
23+
`if` statement can be used together with `else` statement, `else` statement used to execute the code when the condition in `if`is false. The grammar of `if-else` is shown:
2424

2525
```mcfpp
2626
if (condition){
@@ -30,9 +30,9 @@ if (condition){
3030
}
3131
```
3232

33-
`condition`是一个布尔表达式,它的值为`true``false`。如果`condition`的值为`true`,那么`#code1`中的代码块将会被执行;否则,`#code2`中的代码块将会被执行。
33+
`condition` is a boolean expression, it’s value is `true` or `false`. If the value of `condition` is `true`, then `#code1‘ will be execute; Else, ’#code2‘ will be execute.
3434

35-
可以使用`else if`语句用来在`if`语句的条件不成立时判断另一个条件。`if-else if-else`语句的语法如下:
35+
We can use `else if` to add another condition when `if` is false. The grammar of `if-else if-else` is shown below:
3636

3737
```mcfpp
3838
if (condition1){
@@ -44,47 +44,47 @@ if (condition1){
4444
}
4545
```
4646

47-
## while语句和do-while语句
47+
## while statement and do-while statement
4848

49-
`while`语句是一种循环语句,它用来重复执行一个代码块,直到条件不成立。`while`语句的语法如下:
49+
`while` is a loop statement, it can execute a code block repeatedly, until the condition is false. The grammar of `while` statement is:
5050

5151
```mcfpp
5252
while (condition){
5353
#code
5454
}
5555
```
5656

57-
`condition`是一个布尔表达式。如果`condition`的值为`true`,那么则执行`#code`代表的代码块。此后,再次判断`condition`的值,如果`condition`的值为`true`,那么`#code`代表代码块将会被执行;如此循环,直到`condition`的值为`false`
57+
`condition` is an boolean expression, when `condition` is `true`, it’ll execute the code block in `#code`. Then, determine the value of `condition` again. If value of `condition` is `true`, then `#code` will be execute; loop again and again, until the value of `condition` is `false`.
5858

59-
`do-while`语句和`while`类似,但是无论条件是否成立,它都会先执行因此循环体中的语句,而后再判断条件来决定是否继续进行。`do-while`语句的语法如下:
59+
`do-while` statement is similar with `while` statement, but no matter the condition is true or false, it’ll execute the statement in the loop once, and then determine the condition to see continue execution or not. The grammar of `do-while` is shown below:
6060

6161
```mcfpp
6262
do{
6363
#code
6464
}while (condition);
6565
```
6666

67-
## for语句
67+
## for statement
6868

69-
`for`语句是循环的一种稍复杂的版本,它的语法如下:
69+
`for` statement is a more complex version of loop, it’s grammar is:
7070

7171
```mcfpp
7272
for (forinit; condition; forupdate){
7373
#code
7474
}
7575
```
7676

77-
`forinit`是一个初始化表达式,它用来初始化循环变量。`condition`是一个布尔表达式,它用来判断循环是否继续。`forupdate`是一个更新表达式,它用来更新循环变量。`#code`代表了循环体,即循环体中的代码。在运行的时候,`for`语句的执行过程如下:
77+
`forinit` is an initialization expression, used to initialize loop variable. `condition` is a boolean expression, used to determine if the loop keeps going on. `forupdate` is a update expression, used to update the variable of the loop. `#code` represents the loop body, which is the code in the loop. The execute process of `for` is shown below:
7878

79-
1. 执行`forinit`,初始化循环变量。
80-
2. 判断`condition`的值,如果`condition`的值为`true`,则执行`#code`代表的代码块,然后执行`forupdate`,更新循环变量,再次判断`condition`的值。
81-
3. 如果`condition`的值为`false`,则退出循环。
79+
1. Execute `forinit`, initialize the loop variable.
80+
2. Determine the value of `condition`, if the value of `condition` is `true`, execute `#code`, then execute `forupdate`, to update the loop variable, and determine the value of `condition` again.
81+
3. If the value of `condition` is `false`, exit the loop.
8282

83-
`for`循环中,`forinit`声明的变量只在`for`循环中有效。
83+
In `for` loop, the declaration of variable `forinit` only valid in the `for` loop.
8484

85-
## break和continue语句
85+
## break and continue statement
8686

87-
`break`语句用来跳出整个循环,`continue`语句用来跳过本次循环。例如:
87+
`break` statement used to jump out the whole loop, `continue` statement used to skip the current loop. For example:
8888

8989
```mcfpp
9090
for (int i = 0; i < 10; i++){
@@ -98,6 +98,6 @@ for (int i = 0; i < 10; i++){
9898
}
9999
```
100100

101-
在上面的例子中,当`i`的值为`5`时,`break`语句会跳出整个循环;当`i`的值为`3`时,`continue`语句会跳过本次循环,直接进行下一次循环。因此,i在每次循环中的变化为:`0``1``2``4``5`,最后跳出循环。
101+
In this example, when the value of `i` is `5`, `break`will jump out of the loop; when the value of `i` is `3`, `continue` will jump this loop, go to the next loop directly. So, the change of I in each loop are:`0``1``2``4``5`, and finally jump out.
102102

103-
`break``continue`语句只能在循环中使用。
103+
`break` and `continue` statement only can be used in the loop

0 commit comments

Comments
 (0)