回覆列表
  • 1 # 使用者6765375850720

    //計算階乘的私有方法

    private int jiecheng(int i){

    if(i==1)

    return 1;

    else

    return i*jiecheng(i--);

    }

    //for

    private int sumjiechengByFor(int n)

    {

    int sum =0;

    for(int i=1;i

    {

    sum +=jiecheng(i);

    }

    return sum;

    }

    //while

    private int sumjiechengByWhile(int n)

    {

    int sum =0,i=1;

    while(i

    {

    sum +=jiecheng(i);

    i++;

    }

    return sum;

    }

    //dowhile

    private int sumjiechengByDoWhile(int n)

    {

    int sum =0,i=1;

    if(i

    do

    {

    sum +=jiecheng(i);

    i++;

    }while(i

    return sum;

    }

  • 中秋節和大豐收的關聯?
  • 論文重複率低於多少才是合格?