回覆列表
  • 1 # 讓跑步更有力量

    import java.util.Scanner;

    public class TestIncreace {

    void TestInc(int n) throws Exception{

    int []a = new int [n];

    int sum = 0;

    for(int i = 0;i < a.length;i ++){

    a[i] = n % 10;

    n = n / 10;

    sum += a[i];

    }

    System.out.println(sum);

    }

    public static void main(String[] args) throws Exception {

    try{

    TestIncreace t = new TestIncreace();

    System.out.println("請輸入您要測試的資料:");

    Scanner input = new Scanner(System.in);

    int in = input.nextInt();

    t.TestInc(in);//括號內為要測試的資料

    }catch(Exception e){

    System.out.println("非法數字");

    }

    }

    }

  • 中秋節和大豐收的關聯?
  • 生產企劃崗怎麼樣?