提交 c5c921cb 编写于 作者: W wizardforcel

2020-07-07 23:00:41

上级 e46c539e
......@@ -111,7 +111,7 @@ sum = 13
Kotlin 中的标签以[标识符](/kotlin-programming/keywords-identifiers#identifiers "Kotlin identifier")开头,后跟`@`
此处,`test @`是在循环时在外部[处标记的标签。 现在,通过在标签上使用`break`(在这种情况下为`break@test`),可以中断特定的循环。](/kotlin-programming/while-loop "Kotlin while Loop")
此处,`test @`是在外循环上[标记的标签](/kotlin-programming/while-loop "Kotlin while Loop")。 现在,通过在标签上使用`break`(在这种情况下为`break@test`),可以中断特定的循环。
这是一个示例:
......
......@@ -127,7 +127,7 @@ sum = 31
Kotlin 中的标签以[标识符](https://www.programiz.com/kotlin-programming/keywords-identifiers#identifiers "Kotlin identifier")开头,后跟`@`
在此,`outsideloop @`是在循环时在外部[处标记的标签。 现在,通过在标签上使用`continue`(在这种情况下为`continue@outerloop`),可以跳过该迭代的特定循环代码的执行。](https://www.programiz.com/kotlin-programming/while-loop "Kotlin while Loop")
在此,`outsideloop @`是在外循环上[标记的标签](https://www.programiz.com/kotlin-programming/while-loop "Kotlin while Loop")。 现在,通过在标签上使用`continue`(在这种情况下为`continue@outerloop`),可以跳过该迭代的特定循环代码的执行。
* * *
......
......@@ -24,7 +24,7 @@ fun eval(e: Expr): Int =
}
```
在上述程序中,基类`Expr`具有两个派生类`Const`(代表一个数字)和`sum`(代表两个表达式的总和)。 在这里,当表达式时,必须为[中的默认条件使用`else`分支作为默认条件。](/kotlin-programming/when-expression "Kotlin when expression")
在上述程序中,基类`Expr`具有两个派生类`Const`(代表一个数字)和`sum`(代表两个表达式的总和)。 在这里,必须使用`else`分支作为`when`表达式的[默认条件](/kotlin-programming/when-expression "Kotlin when expression")
现在,如果您从`Expr`类派生新的子类,则编译器将不会检测到任何东西,因为`else`分支对其进行处理会导致错误。 如果在添加新的子类时编译器发出错误,那就更好了。
......
......@@ -40,7 +40,7 @@ Factorial of 10 = 3628800
但是,它仍然不足以存储较大数字(例如 100)的值。 对于不能存储在长变量中的结果,我们使用在`java.math`库中声明的`BigInteger`变量。
以下是等效的 Java 代码:[查找数字的阶乘的 Java 程序](/java-programming/examples/factorial)
以下是等效的 Java 代码:[查找数字的阶乘的 Java 程序](/java-programming/examples/factorial)
* * *
......
......@@ -6,7 +6,7 @@
正数 1、2、3... 称为自然数。 下面的程序从用户处获取一个正整数,然后计算得出给定数字的总和。
您也可以使用循环[查找自然数的总和。 但是,您将在此处学习使用递归解决此问题。](/kotlin-programming/examples/sum-natural-numbers "Natural number sum using loops in Kotlin")
您也可以使用循环[查找自然数的总和](/kotlin-programming/examples/sum-natural-numbers "Natural number sum using loops in Kotlin")。 但是,您将在此处学习使用递归解决此问题。
## 示例:使用递归的自然数之和
......
......@@ -12,7 +12,7 @@ factorial of n (n!) = 1 * 2 * 3 * 4 * ... * n
负数的阶乘不存在。 阶乘 0 为 1。
在此示例中,您将学习使用递归查找数字的阶乘。 访问此页面了解如何使用循环查找数字的[阶乘](/kotlin-programming/examples/factorial "Kotlin program to calculate factorial using loop")
在此示例中,您将学习使用递归查找数字的阶乘。 访问此页面了解如何使用循环查找数字的[阶乘](/kotlin-programming/examples/factorial "Kotlin program to calculate factorial using loop")
## 示例:使用递归的阶乘
......
......@@ -6,7 +6,7 @@
该程序采用两个正整数,并使用递归计算 <abbr title="Greatest Common Divisor">GCD</abbr>
访问此页面以了解如何使用循环来[计算 <abbr title="Greatest Common Divisor">GCD</abbr> 。](/kotlin-programming/examples/hcf-gcd "GCD using loops in Kotlin")
访问此页面以了解如何使用循环来[计算 GCD](/kotlin-programming/examples/hcf-gcd "GCD using loops in Kotlin")
## 示例:使用递归的两个数字的 GCD
......
......@@ -16,7 +16,7 @@ c1 = r2
product[r1][c2]
```
您也可以使用函数[乘以两个矩阵。](/kotlin-programming/examples/multiply-matrix-function "multiply two matrices using functions")
您也可以使用函数[相乘两个矩阵](/kotlin-programming/examples/multiply-matrix-function "multiply two matrices using functions")
## 示例:将两个矩阵相乘的程序
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册