Java-功能:求1!+2!+3!+4!+5!。


public class Main {
    public static void main(String[] args) {
        fun();
    }
    public static void fun(){
        int n,j;
        //float s=0.0,t=1.0;//此行語句有錯誤,改正后填到下側空格內
        float s=0.0f,t=1.0f;
        for(n=1;n<=5;n++){
            //s=1;//此行語句有錯誤,改正后填到下側空格內
            t=1;
            for(j=1;j<=n;j++){
                //t=t*n;//此行語句有錯誤,改正后填到下側空格內
                t=t*j;
            }
            //s+t=s;//此行語句有錯誤,改正后填到下側空格內
            s=s+t;
        }
        System.out.printf("jiecheng=%.0f\n",s);
    }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM