<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # Java 程序:將`Integer`分解為數字 > 原文: [https://beginnersbook.com/2019/02/java-program-to-break-integer-into-digits/](https://beginnersbook.com/2019/02/java-program-to-break-integer-into-digits/) 在本教程中,我們將編寫一個 java 程序來將輸入整數分成數字。例如,如果輸入的數字是 912,則程序應顯示數字`2,1,9`以及它們在輸出中的位置。 ## Java 示例:將整數分成數字 這里我們使用`Scanner`類來[從用戶](https://beginnersbook.com/2014/07/java-program-to-get-input-from-user/)獲取輸入。在第一個[`while`循環](https://beginnersbook.com/2015/03/while-loop-in-java-with-examples/)中,我們計算輸入數字中的數字,然后在第二個`while`循環中,我們使用[模數運算符](https://beginnersbook.com/2017/08/operators-in-java/)從輸入數字中提取數字。 ```java package com.beginnersbook; import java.util.Scanner; public class JavaExample { public static void main(String args[]) { int num, temp, digit, count = 0; //getting the number from user Scanner scanner = new Scanner(System.in); System.out.print("Enter any number:"); num = scanner.nextInt(); scanner.close(); //making a copy of the input number temp = num; //counting digits in the input number while(num > 0) { num = num / 10; count++; } while(temp > 0) { digit = temp % 10; System.out.println("Digit at place "+count+" is: "+digit); temp = temp / 10; count--; } } } ``` **輸出:** ![Java Program to break Integer into Digits](https://img.kancloud.cn/f4/bd/f4bd023d0c83914c1dfc9ba5794cc4d9_792x1024.jpg)
                  <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>

                              哎呀哎呀视频在线观看