<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Kotlin 程序:計算商數和余數 > 原文: [https://www.programiz.com/kotlin-programming/examples/compute-quotient-remainder](https://www.programiz.com/kotlin-programming/examples/compute-quotient-remainder) #### 在此程序中,您將學習根據 Kotlin 中給定的除數和除數來計算商和余數。 ## 示例:計算商和余數 ```kt fun main(args: Array<String>) { val dividend = 25 val divisor = 4 val quotient = dividend / divisor val remainder = dividend % divisor println("Quotient = $quotient") println("Remainder = $remainder") } ``` 運行該程序時,輸出為: ```kt Quotient = 6 Remainder = 1 ``` * * * 在上面的程序中,兩個數字`25`(除數)和`4`(除數)分別存儲在兩個變量`dividend`和`divisor`中。 與 Java 不同,在 Kotlin 中會自動為它們分配`Int`類型。 現在,為了找到商,我們使用`/`運算符將`dividend`除以`divisor`。 由于`dividend`和`divisor`均為`Int`,因此結果也將計算為`Int`。 因此,在數學上,即使`25/4`結果為`6.25`,由于兩個操作數均為`Int`,因此`quotient`變量僅存儲`6`(整數部分)。 同樣,要找到余數,我們使用`%`運算符。 因此,`25/4`的其余部分,即`1`存儲在`Int`變量`remainder`中。 最后,使用`println()`函數在屏幕上打印`quotient`和`remainder`。 * * * 這是 Java 中的等效代碼:[計算 Java 中的商和余數](/java-programming/examples/compute-quotient-remainder "Java Program to Compute Quotient and Remainder ")
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看